
Originally Posted by
shoa
What will I have to do to test with the classes that extend the SimpleFormController. I think that I donot have to test ffor functions like onSubmit, onBackingObject.....).
You should only test *your* code. If you have overridden any of those methods, sure, test them, but don't bother testing Spring's code
.
In the same token, you shouldn't really be testing the workflow of a class, just it's individual methods.

Originally Posted by
shoa
For example, I have in my form
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors){
MyObject myObject = (MyObject)command;
myObjectManager.add(myObject);
return new ModelAndView(new RedirectView(getSuccessView()));
}
Simply test the method in isolation:
Code:
MyObject myCommand = new MyObject();
MyController controller = new MyController();
ModelAndView mav = controller.onSubmit(myCommand);
View view = mav.getView();
assertTrue("view is type redirect", RedirectView.class, view.getClass());
etc.
Note I am using the onSubmit(Object) method, not your method which takes in all the parameters. If you do want to test that, then you can create MockHttpServletRequest and MockHttpServletResponse etc.
Remember, it is much better to have lots of little tests that a single aspect...
HTH