A Service with business logic needs to be tested to ensure it functions correctly. In order to do this, a Service like the following can be used:
@RunWith(MockitoJUnitRunner::class)@ActiveProfiles("dev")class MovieServiceTest { @Mock lateinit var movieRepository: MovieRepository; lateinit var movieService: MovieService;
In the preceding test case for MovieService , MovieRepository is annotated with @Mock. During Service, test mocking is done using the Mockito library just to mock repository method invocations and verify the correct invocation. Consider the following code:
@Before fun setup() { movieService = MovieService(movieRepository); }
The preceding code is used to create an instance of MovieService with a mocked ...