Reputation: 5407
I have a question about testing. there is a controller with handler methods :
@Controller
@RequestMapping("/something")
public class MyController{
@RequestMapping(value = "/getSomething" , method = POST, produces = {JSON}, consumes = {JSON})
@ResponseBody
public MyClass2 getSomething(@RequestBody MyClass myObj) {
.........
}
}
Should I do any annotation's virification in my tests? Like :
@Test
public void verityMethodGetSomethihg(){
//check that there is the POST method
//check that the method produces a JSON
//check that the method consumes a JSON
}
PS Also , should do I check anywhere that there is method-handler a mapping for /getSomething?
Thanks
Upvotes: 1
Views: 24
Reputation: 691715
What you should do is up to you. If you consider it's a useful test to have, then do it. If you consider it's useless because, for example, you have an extensive functional test suite that tests your application, then don't.
Now how to do it? Spring MVC comes with a testing framework allowing to start a fake web application context, send a request to your app and test the result. It's extensively described in the documentation.
Upvotes: 1