Unit testing

Unit testing is a very important part of developing maintainable applications. We will be using the Spring MVC Mock framework to unit test the Controllers that we will write in this chapter. We will add in a dependency on the Spring test framework to use the Spring MVC Mock framework:

    <dependency>       <groupId>org.springframework</groupId>       <artifactId>spring-test</artifactId>       <scope>test</scope>     </dependency>

The approach we will be taking would involve the following:

  1. Setting up the Controller to test.
  2. Writing the test method.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.