Create unit tests of the Spring MVC controller

We will take the example of the Spring MVC from this chapter as a target application to test and execute unit testing. We have the EmployeeController class as a target class to test.

You'll find the following code in EmployeeController.java:

package org.packt.Spring.chapter7.springmvc.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/employee") public class EmployeeController { @RequestMapping(method = RequestMethod.GET) public String welcomeEmployee(ModelMap model) { model.addAttribute("name", "Hello ...

Get Spring: Developing Java Applications for the Enterprise 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.