【发布时间】:2019-10-02 02:32:54
【问题描述】:
我正在尝试进行一个集成测试,该测试会为 void 方法引发异常以模拟停机服务。该方法有一个字符串参数和一个多部分文件作为参数,即使为具有两个字符串参数的 void 方法引发异常,它似乎也不起作用。
工作集成测试:
@Test
@DisplayName("500 response -- downed case mgmt microservice")
public void downedCaseMgmt() throws Exception {
BDDMockito.doThrow(new RuntimeException("mocking an error")).when(reportEventService).reportDocUpload(ArgumentMatchers.any(String.class), ArgumentMatchers.anyString());
//Rest assured portion
given().
multiPart("file", xlsxGoodFile).
params(paramsMap).
when().
post("").
then().
statusCode(500);
}
非工作集成测试:
@Test
@DisplayName("500 response -- downed object storage")
public void downedObjectStorage() throws Exception {
BDDMockito.doThrow(new RuntimeException("mocking an error")).when(objectStorageService).saveFileToObjectStorage(ArgumentMatchers.anyString(), ArgumentMatchers.any(File.class));
//Rest assured portion
given().
multiPart("file", xlsxGoodFile).
params(paramsMap).
when().
post("").
then().
statusCode(500);
}
【问题讨论】:
标签: mockito integration-testing void