fix(接口测试): 修复接口含失败断言的请求时环境开启了不匹配的误报导致接口结果应为失败实为成功的缺陷

--bug=1009950 --user=宋天阳 【接口测试】开启误报库后,断言有失败的,但是用例执行结果是通过
https://www.tapd.cn/55049933/s/1099392
This commit is contained in:
song-tianyang 2022-01-26 16:54:44 +08:00 committed by xiaomeinvG
parent 35d3330b14
commit fdc8a8c615
2 changed files with 11 additions and 1 deletions

View File

@ -28,6 +28,9 @@ public class ScriptFilter {
}
public static void verify(String language, String label, String script) {
if(language == null){
language = "";
}
if (StringUtils.isNotEmpty(script)) {
final StringBuffer buffer = new StringBuffer();
switch (language) {

View File

@ -20,9 +20,14 @@ public class ErrorReportLibraryUtil {
ErrorReportLibraryParseDTO returnDTO = new ErrorReportLibraryParseDTO();
if (result != null && result.getResponseResult() != null && CollectionUtils.isNotEmpty(result.getResponseResult().getAssertions())) {
List<ResponseAssertionResult> errorReportAssertionList = new ArrayList<>();
boolean hasOtherErrorAssertion = false;
for (ResponseAssertionResult assertion : result.getResponseResult().getAssertions()) {
if (StringUtils.startsWith(assertion.getContent(), ERROR_CODE_START)) {
errorReportAssertionList.add(assertion);
}else {
if(!assertion.isPass()){
hasOtherErrorAssertion = true;
}
}
}
if (CollectionUtils.isNotEmpty(errorReportAssertionList)) {
@ -41,7 +46,9 @@ public class ErrorReportLibraryUtil {
if (result.getResponseResult() != null
&& StringUtils.equalsIgnoreCase(result.getResponseResult().getResponseCode(), "200")
&& result.getError() > 0) {
result.setError(result.getError() - 1);
if(!hasOtherErrorAssertion){
result.setError(result.getError() - 1);
}
}
result.setTotalAssertions(result.getTotalAssertions() - unMatchErrorReportAssertions.size());
result.getResponseResult().getAssertions().removeAll(unMatchErrorReportAssertions);