fix(接口自动化): 添加断言规则,修复执行报告缺陷
This commit is contained in:
parent
fbda7b423f
commit
caa7a5d4d7
|
@ -43,4 +43,8 @@ public class ScenarioResult {
|
|||
public void addPassAssertions(int count) {
|
||||
this.passAssertions += count;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return error + success;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,5 @@ public class TestResult {
|
|||
this.passAssertions += count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -298,13 +298,15 @@ public class ApiAutomationService {
|
|||
testPlan.setHashTree(new LinkedList<>());
|
||||
HashTree jmeterHashTree = new ListedHashTree();
|
||||
try {
|
||||
boolean isFirst = true;
|
||||
for (ApiScenarioWithBLOBs item : apiScenarios) {
|
||||
MsThreadGroup group = new MsThreadGroup();
|
||||
group.setLabel(item.getName());
|
||||
group.setName(UUID.randomUUID().toString());
|
||||
// 批量执行的结果直接存储为报告
|
||||
if (apiScenarios.size() == 1) {
|
||||
if (isFirst) {
|
||||
group.setName(request.getId());
|
||||
isFirst = false;
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
|
|
@ -107,14 +107,14 @@ public class ApiScenarioReportService {
|
|||
return report;
|
||||
}
|
||||
|
||||
private TestResult createTestResult(TestResult result) {
|
||||
private TestResult createTestResult(String testId, ScenarioResult scenarioResult) {
|
||||
TestResult testResult = new TestResult();
|
||||
testResult.setTestId(result.getTestId());
|
||||
testResult.setTotal(result.getTotal());
|
||||
testResult.setError(result.getError());
|
||||
testResult.setPassAssertions(result.getPassAssertions());
|
||||
testResult.setSuccess(result.getSuccess());
|
||||
testResult.setTotalAssertions(result.getTotalAssertions());
|
||||
testResult.setTestId(testId);
|
||||
testResult.setTotal(scenarioResult.getTotal());
|
||||
testResult.setError(scenarioResult.getError());
|
||||
testResult.setPassAssertions(scenarioResult.getPassAssertions());
|
||||
testResult.setSuccess(scenarioResult.getSuccess());
|
||||
testResult.setTotalAssertions(scenarioResult.getTotalAssertions());
|
||||
return testResult;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class ApiScenarioReportService {
|
|||
ApiScenarioReport report = editReport(scenarioResult);
|
||||
// 报告详情内容
|
||||
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
||||
TestResult newResult = createTestResult(result);
|
||||
TestResult newResult = createTestResult(result.getTestId(), scenarioResult);
|
||||
List<ScenarioResult> scenarioResults = new ArrayList();
|
||||
scenarioResult.setName(report.getScenarioName());
|
||||
scenarioResults.add(scenarioResult);
|
||||
|
@ -152,10 +152,9 @@ public class ApiScenarioReportService {
|
|||
for (ScenarioResult item : result.getScenarios()) {
|
||||
// 更新报告状态
|
||||
ApiScenarioReport report = editReport(item);
|
||||
|
||||
// 报告详情内容
|
||||
ApiScenarioReportDetail detail = new ApiScenarioReportDetail();
|
||||
TestResult newResult = createTestResult(result);
|
||||
TestResult newResult = createTestResult(result.getTestId(), item);
|
||||
List<ScenarioResult> scenarioResults = new ArrayList();
|
||||
item.setName(report.getScenarioName());
|
||||
scenarioResults.add(item);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<ms-container v-loading="loading">
|
||||
<ms-main-container>
|
||||
<el-card>
|
||||
<section class="report-container">
|
||||
<section class="report-container" v-if="this.report.testId">
|
||||
|
||||
<ms-api-report-view-header :debug="debug" :report="report" @reportExport="handleExport" @reportSave="handleSave"/>
|
||||
|
||||
|
|
|
@ -396,16 +396,16 @@
|
|||
this.addComponent('ConstantTimer')
|
||||
}
|
||||
},
|
||||
// {
|
||||
// title: this.$t('api_test.automation.external_import'),
|
||||
// show: this.showButton("OT_IMPORT"),
|
||||
// titleColor: "#409EFF",
|
||||
// titleBgColor: "#EEF5FE",
|
||||
// icon: "next_plan",
|
||||
// click: () => {
|
||||
// this.addComponent('OT_IMPORT')
|
||||
// }
|
||||
// },
|
||||
{
|
||||
title: this.$t('api_test.definition.request.assertions_rule'),
|
||||
show: this.showButton("Assertions"),
|
||||
titleColor: "#A30014",
|
||||
titleBgColor: "#F7E6E9",
|
||||
icon: "next_plan",
|
||||
click: () => {
|
||||
this.addComponent('Assertions')
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.automation.customize_req'),
|
||||
show: this.showButton("CustomizeReq"),
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
import MsApiAssertionText from "./ApiAssertionText";
|
||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||
import MsApiAssertionDuration from "./ApiAssertionDuration";
|
||||
import {ASSERTION_TYPE, Assertions, JSONPath, Scenario} from "../../model/ApiTestModel";
|
||||
import {ASSERTION_TYPE, JSONPath, Scenario} from "../../model/ApiTestModel";
|
||||
import MsApiAssertionsEdit from "./ApiAssertionsEdit";
|
||||
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
|
||||
import MsApiAssertionJsr223 from "./ApiAssertionJsr223";
|
||||
|
|
Loading…
Reference in New Issue