I have an annotated controller with a method that expects a model and a binding result
@RequestMapping(method = RequestMethod.POST)
public ModelAndView submit(@ModelAttribute(“user”) User user, BindingResult bindingResult) {
//do something
}
How do I test the binding result? If I call the method with a user and a binding result then I’m not testing the binding process. I figure there myst be something that takes a MockHttpServletRequest and returns the model and the binding result, any suggestions?
Are you trying to test the binding (which happens before this method would be called) or are you trying to test the “submit” handler method?
You can test the binding with something like this: