[英]Junit testcase - error - status expected:<200> but was:<500>
Am running Junit test cases for my project module.正在为我的项目模块运行 Junit 测试用例。 After the execution of the test case am getting the below error report.
执行测试用例后,我收到以下错误报告。
ClaimControllerTest.shouldReturnClaimWithValidationResult:417 Status expected:<200> but was:<500>
Am using the below maven comment to execute the test case for a specific module.我使用下面的 maven 注释来执行特定模块的测试用例。
mvn clean compile verify -Ptest
But, my project have many module dependency.但是,我的项目有很多模块依赖。 How can i execute my test case for my complete project ( will all modules )
我如何为我的完整项目执行我的测试用例(所有模块)
The above error is pointing to the below piece of test case code上面的错误指向下面的测试用例代码
mockMvc.perform(get(String.format("/claims/%d/validation-result", claim.getId())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.catClaimNumber").value(claim.getCatClaimNumber().intValue()))
.andExpect(jsonPath("$.validationResult.programErrorCode").value("UNTHRZD_EXTRNL_USR"))
.andExpect(jsonPath("$.validationResult.hasErrors").value(true));
Update 1 :更新 1:
Am seeing the below null pointer exception after doing Sys out在执行 Sys 后看到下面的空指针异常
2019-01-03 15:46:27,401 [main] ERROR api.controller.BaseController: 83 - Unhandled exception while processing request for URL : http://localhost/claims/1901/validation-result with exception : null java.lang.NullPointerException
For the below code :对于以下代码:
mockMvc.perform(get(String.format("/claims/%d/validation-result", claim.getId()))).andDo(print());
It is telling you that instead of a success code 200 from calling your rest endpoint, it received an error code of 500. It means that your rest end point threw an exception.它告诉您,调用您的休息端点时收到的错误代码不是 200,而是 500。这意味着您的休息端点抛出了异常。
you may want to print the full response with exception to further debug您可能想要打印完整的响应,但要进一步调试
mockMvc.perform(get(String.format("/claims/%d/validation-result", claim.getId()))).andDo(print());
You have two questions:你有两个问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.