feat(误报库): 修复响应码不是200且误报库未匹配到的情况下整体请求判断为通过的缺陷
修复响应码不是200且误报库未匹配到的情况下整体请求判断为通过的缺陷
This commit is contained in:
parent
a1cdc50d81
commit
3bd751f23b
|
@ -26,24 +26,26 @@ public class ErrorReportLibraryUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(errorReportAssertionList)) {
|
if (CollectionUtils.isNotEmpty(errorReportAssertionList)) {
|
||||||
List<ResponseAssertionResult> removeList = new ArrayList<>();
|
List<ResponseAssertionResult> unMatchErrorReportAssertions = new ArrayList<>();
|
||||||
for (ResponseAssertionResult assertion : errorReportAssertionList) {
|
for (ResponseAssertionResult assertion : errorReportAssertionList) {
|
||||||
if (assertion.isPass()) {
|
if (assertion.isPass()) {
|
||||||
String errorCode = StringUtils.substring(assertion.getContent(), ERROR_CODE_START.length());
|
String errorCode = StringUtils.substring(assertion.getContent(), ERROR_CODE_START.length());
|
||||||
returnDTO.getErrorCodeList().add(errorCode);
|
returnDTO.getErrorCodeList().add(errorCode);
|
||||||
} else {
|
} else {
|
||||||
removeList.add(assertion);
|
unMatchErrorReportAssertions.add(assertion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(removeList)) {
|
if (CollectionUtils.isNotEmpty(unMatchErrorReportAssertions)) {
|
||||||
if (result.getError() > 0) {
|
// 未被误报断言匹配到的结果,清除该请求的误报断言记录,并将断言涉及到的统计结果恢复正常
|
||||||
|
if (result.getResponseResult() != null
|
||||||
|
&& StringUtils.equalsIgnoreCase(result.getResponseResult().getResponseCode(), "200")
|
||||||
|
&& result.getError() > 0) {
|
||||||
result.setError(result.getError() - 1);
|
result.setError(result.getError() - 1);
|
||||||
}
|
}
|
||||||
result.setTotalAssertions(result.getTotalAssertions() - removeList.size());
|
result.setTotalAssertions(result.getTotalAssertions() - unMatchErrorReportAssertions.size());
|
||||||
result.getResponseResult().getAssertions().removeAll(removeList);
|
result.getResponseResult().getAssertions().removeAll(unMatchErrorReportAssertions);
|
||||||
//修改由于误报断言导致的执行结果
|
if (result.getError() == 0 && !result.isSuccess()) {
|
||||||
if(result.getError() == 0 && !result.isSuccess()){
|
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,13 @@
|
||||||
<ms-scenario-results v-on:requestResult="requestResult" :console="content.console"
|
<ms-scenario-results v-on:requestResult="requestResult" :console="content.console"
|
||||||
:treeData="fullTreeNodes" ref="failsTree"/>
|
:treeData="fullTreeNodes" ref="failsTree"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
<el-tab-pane name="errorReport" v-if="content.errorCode > 0">
|
||||||
|
<template slot="label">
|
||||||
|
<span class="fail">{{ $t('error_report_library.option.name') }}</span>
|
||||||
|
</template>
|
||||||
|
<ms-scenario-results v-on:requestResult="requestResult" :console="content.console"
|
||||||
|
:treeData="fullTreeNodes" ref="errorReportTree"/>
|
||||||
|
</el-tab-pane>
|
||||||
<el-tab-pane name="console">
|
<el-tab-pane name="console">
|
||||||
<template slot="label">
|
<template slot="label">
|
||||||
<span class="console">{{ $t('api_test.definition.request.console') }}</span>
|
<span class="console">{{ $t('api_test.definition.request.console') }}</span>
|
||||||
|
@ -119,6 +126,8 @@ export default {
|
||||||
filter(index) {
|
filter(index) {
|
||||||
if (index === "1") {
|
if (index === "1") {
|
||||||
this.$refs.failsTree.filter(index);
|
this.$refs.failsTree.filter(index);
|
||||||
|
} else if (this.activeName === "errorReport") {
|
||||||
|
this.$refs.errorReportTree.filter("errorReport");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
|
|
|
@ -43,7 +43,15 @@ export default {
|
||||||
}
|
}
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
if (data.value) {
|
if (data.value) {
|
||||||
return data.value.error > 0;
|
if (value === 'errorReport') {
|
||||||
|
if (data.errorCode && data.errorCode !== "") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!data.errorCode || data.errorCode === "") {
|
||||||
|
return data.value.error > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue