Spring Unit Testing with Mockito

Let's rewrite the unit test by mocking the dependency using Mockito.

The RecommenderImplementation class has a dependency on the Filter interface. Ideally, when writing unit tests, we should only focus on the class under test and mock the dependencies instead of initializing the dependency. We will now write a test for the same class using Mockito.

mockito-core dependency

To test using the Mockito framework, we need the mockito-core dependency, which can be added to pom.xml as follows:

Get hands-on with 1400+ tech skills courses.