java - jUnit testing @RequestParam, but my test doesn't give any value to it -
how can test requested parameters coming html spring controller?
@requestmapping(value = "foo", method = requestmethod.post) public string foo(@requestparam(value="bar", required=false) string bar{ if(bar==null || bar.length()==0){ return "error"; } return "success"; }
i don't understand why isn't working?
@test public void testfoo() throws exception { mockmvc.perform(post("/foo") .param("bar", "this not null")) .andexpect(view().name("success")); }
i get: java.lang.assertionerror: view name expected:"success" was:"error"
so want controller test skips validation part , goes "success", somehow test isn't giving value bar variable. how make work?
Comments
Post a Comment