LoginController { @GetMapping("/signup") public ModelAndView signup() { ModelAndView modelAndView = new ModelAndView(); User user = new User(); modelAndView.addObject("user", user); modelAndView.setViewName("signup"); return modelAndView; } LoginController(CustomUserDetailsServiceImpl userService); @GetMapping("/login") ModelAndView login(); @GetMapping("/signup") ModelAndView signup(); @PostMapping("/signup") ModelAndView createNewUser(@Valid @ModelAttribute User user, BindingResult bindingResult); @GetMapping("/dashboard") ModelAndView dashboard(); @GetMapping({ "/", "/home" }) ModelAndView home();  }
@Test void testSignup() throws Exception { this.mockMvc.perform(get("/signup")).andExpect(status().isOk()).andExpect(view().name("signup")) .andExpect(model().attributeExists("user")).andExpect(model().errorCount(0)) .andExpect(content().contentType("text/html;charset=UTF-8")); }