November 2016
Intermediate to advanced
944 pages
21h 1m
English
It is now time to write our first unit test.
We will focus on writing tests at the controller level because we have little to no business code or service. The key to writing tests for Spring MVC is the org.springframework.boot:spring-boot-starter-test dependency in our classpath. It will add a few very useful libraries, such as these:
hamcrest: This is JUnit's assertion librarymockito: This is a mocking libraryspring-test: This is the Spring testing libraryWe will test the redirection to the profile page that is created when the user hasn't created their profile yet.
We already have an autogenerated test called MasterSpringMvc4ApplicationTests. It is the most basic kind of test one can write with the Spring test framework: it ...
Read now
Unlock full access