• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to unit test @ModelAttribute in Spring MVC controller

 
Nitesh Patel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to develop unit test for below Spring MVC controller's method using Junit but I could not figure out how can I unit test the @ModelAttribute. Can anyone please guide me ?


Regards,
Nitesh
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about in your unit test just doing



Now the BindingResult object is a different matter. You have to instantiate one or create a mock of one. BindingResult is an interface, and there are implementations. Here is the Javadoc for it
http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/validation/BindingResult.html

Good Luck

Mark
 
Nitesh Patel
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark,


Regards,
Nitesh
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic