Unit Testing in Spring

Learn how to write two simple unit tests using the JUnit framework to test a method.

When writing tests, the foremost thing to remember is that the test code should always be separate from the production code. We will write all our tests in src/test/java. This will ensure that the test code is never part of the deployable jar or war and stays in our repository.

We will now write unit tests for the RecommenderImplementation class. The code of the class is reproduced below:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.