Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Testing Service Layer

Pragya Keshap answered on February 28, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Unit Testing the Service Layer
  • Testing API Layer

  • Testing Service Layer

    0

    @Mock annotation creates a mock implementation for the class it is annotated with.

    @InjectMocks also creates the mock implementation, additionally injects the dependent mocks that are marked with the annotations @Mock into it.

    In UserServiceTest we are mocking UserRespository which means we don’t care about how the repository layer works. As the dependencies are mocked, we have to define how the method calls to the mocked object should behave, we can do that by using the method call chain Mockito.when().thenReturn()

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 28 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.