I am using MockMVC to test my controller.
I have the following controller:
public class A{
...
@RequestMapping("/get")
public List<ADTO> get(@RequestParam(defaultValue = "15", required = false) Integer limit) throws IOException {
if(limit <= 0 || limit >= 50){
throw new IllegalArgumentException();
}
...
return aDTOs;
}
}
And my current test looks like this:
@Test
public void testGetAllLimit0() throws Exception {
mockMvc.perform(get("/A/get")
.param("limit","0")
)
.andDo(print())
.andExpect(...);
}
I am instantiating MockMVC with this:
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
How can I take care of that exception thrown in my controller?
Aucun commentaire:
Enregistrer un commentaire