refactor(接口测试): 修复接口测试报告导出时状态不对的缺陷

--bug=1011423 --user=宋天阳 【接口测试】任务中心查看场景集合报告,导出报告,和页面上显示的不一致
https://www.tapd.cn/55049933/s/1122920
This commit is contained in:
song-tianyang 2022-03-22 11:44:06 +08:00 committed by CountryBuilder
parent 09481ca01f
commit d3fe9e20c4
4 changed files with 28 additions and 10 deletions

View File

@ -227,7 +227,7 @@ public class ApiScenarioReportStructureService {
stepError.set(stepError.longValue() + 1);
} else if (StringUtils.equalsIgnoreCase(step.getTotalStatus(), "errorCode")) {
stepErrorCode.set(stepErrorCode.longValue() + 1);
} else {
} else if (!StringUtils.equalsIgnoreCase(step.getTotalStatus(), "success")) {
stepUnExecute.set(stepUnExecute.longValue() + 1);
}
}
@ -277,7 +277,7 @@ public class ApiScenarioReportStructureService {
}
}
if (StringUtils.isNotEmpty(dto.getErrorCode())) {
dto.setTotalStatus("errorReport");
dto.setTotalStatus("errorCode");
}
if (CollectionUtils.isNotEmpty(dto.getChildren())) {
@ -304,7 +304,7 @@ public class ApiScenarioReportStructureService {
failCount++;
} else if (StringUtils.equalsIgnoreCase(child.getTotalStatus(), "success")) {
successCount++;
} else if (StringUtils.equalsIgnoreCase(child.getTotalStatus(), "errorReport")) {
} else if (StringUtils.equalsIgnoreCase(child.getTotalStatus(), "errorCode")) {
errorReportCount++;
}
}
@ -319,7 +319,7 @@ public class ApiScenarioReportStructureService {
if (failCount > 0) {
dto.setTotalStatus("fail");
} else if (errorReportCount > 0) {
dto.setTotalStatus("errorReport");
dto.setTotalStatus("errorCode");
} else {
dto.setTotalStatus("success");
}
@ -327,7 +327,7 @@ public class ApiScenarioReportStructureService {
if (errorReportCount > 0) {
dto.setTotalStatus("fail");
} else if (failCount > 0) {
dto.setTotalStatus("errorReport");
dto.setTotalStatus("errorCode");
} else {
dto.setTotalStatus("success");
}
@ -427,7 +427,7 @@ public class ApiScenarioReportStructureService {
reportDTO.setTotal(reportResults.size());
reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "Error")).collect(Collectors.toList()).size());
reportDTO.setUnExecute(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "STOP")).collect(Collectors.toList()).size());
reportDTO.setErrorCode(reportResults.stream().filter(e -> StringUtils.isNotEmpty(e.getErrorCode())).collect(Collectors.toList()).size());
reportDTO.setErrorCode(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "errorReportResult")).collect(Collectors.toList()).size());
reportDTO.setPassAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getPassAssertions).sum());
reportDTO.setTotalAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getTotalAssertions).sum());
@ -489,7 +489,7 @@ public class ApiScenarioReportStructureService {
AtomicLong stepError = new AtomicLong();
AtomicLong stepTotal = new AtomicLong();
reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute()));
reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute() -reportDTO.getScenarioErrorReport()));
//统计步骤数据
AtomicLong stepErrorCode = new AtomicLong();

View File

@ -468,6 +468,9 @@ export default {
formatExportApi(array, scenario) {
array.forEach(item => {
if (this.stepFilter && this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1) {
if(item.errorCode){
item.value.errorCode = item.errorCode;
}
scenario.requestResults.push(item.value);
}
if (item.children && item.children.length > 0) {

View File

@ -53,7 +53,18 @@
</api-report-reqest-header-item>
<api-report-reqest-header-item :title="$t('api_report.result')">
<el-tag size="mini" type="success" v-if="request.success">
<el-tag v-if="request.unexecute">{{
$t('api_test.home_page.detail_card.unexecute')
}}
</el-tag>
<el-tag v-else-if="!request.success && request.status && request.status==='unexecute'">{{
$t('api_test.home_page.detail_card.unexecute')
}}
</el-tag>
<el-tag v-else-if="request.errorCode" class="ms-test-error_code">
{{ $t('error_report_library.option.name') }}
</el-tag>
<el-tag size="mini" type="success" v-else-if="request.success">
{{$t('api_report.success')}}
</el-tag>
<el-tag size="mini" type="danger" v-else>
@ -138,6 +149,10 @@
.request-top div {
margin-top: 10px;
}
.ms-test-error_code {
color: #F6972A;
background-color: #FDF5EA;
border-color: #FDF5EA;
}
</style>

View File

@ -216,7 +216,7 @@ export default {
formatter: '{b}: {c} ({d}%)'
},
title: [{
text: this.content.total,
text: (this.content.success + this.content.error +this.content.unExecute +this.content.errorCode),
subtext: this.$t('api_report.request'),
top: 'center',
left: 'center',