This is my controller class
@Controller
public class myClass extends BaseController {
@RequestMapping(value = "/myList", method = RequestMethod.POST, consumes = "application/json")
public @ResponseBody MyBaseVO getMyList(@RequestBody MyBaseVO requestObj) throws Exception {
requestObj.setEntity(getConfig(LanguageConstant.MY_MODULE_ID));
MyBaseVO response = (MyBaseVO) this.execute(requestObj,LanguageConstant.MY_MODULE_ID);
return response;
}
}
I wanted to write a mock test case but stuck at this point, also i'm not sure i am doing correct or not. Can anyone help me in this.
public class myClassTest{
myClass spy = Mockito.spy(new myClass ());
Mockito.when(spy.getMyList(itemRequest)).thenReturn(itemReq);
}
I am not sure how to use url myList
in testcase and request and response object. I have created a json file of my request and response. Since it is using parent class therefore I am using spy for my testcase.
Since you are using Spring, you should have a look at Spring's platform Mock Test implementation for Spring MVC.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.