错误ExportRestClientServiceImplTest.testRetriveDataInternalServerError InvalidUseOfMatchers

时间:2018-06-05 11:26:19

标签: maven maven-surefire-plugin

使用maven运行时出现 InvalidUseOfMatchers 异常,但如果我右键单击并运行单个测试文件,则可以正常工作。

@Test(expected=BadRequest.class)
public void testRetriveDataBadRequest() throws Exception{
    ObjectMapper mapper = new ObjectMapper();
    ExportRequest request = mapper.readValue(EXPORT_REQUEST_CSV_JSON_NOTIFICATIONS, ExportRequest.class);
    Map<String, String> params = getHeaders();
    for(ExportRestCriteria restCrit : request.getRestCriteria()){
        ResponseEntity<String> response = new ResponseEntity<String>("{\"errormessage\":\"errormessage\"}", HttpStatus.BAD_GATEWAY);
        when(restTemplate.exchange(any(URI.class), any(HttpMethod.class), any(HttpEntity.class), any(Class.class))).thenReturn(response);
        this.restClient.retriveData(restCrit.getUrl(), restCrit.getMethod(), restCrit.getHeaders(), params, 
                restCrit.getTotalRecordCount(), restCrit.getMapping().getRootElement());
    }
}

有人可以建议我在这里缺少什么..

0 个答案:

没有答案