fix(接口自动化): 报告优化

This commit is contained in:
fit2-zhao 2020-12-24 18:15:28 +08:00
parent d9f1f19e7d
commit 4e8deba17b
3 changed files with 47 additions and 9 deletions

View File

@ -90,6 +90,13 @@ public class ApiAutomationController {
apiAutomationService.run(request);
}
@PostMapping(value = "/run/batch")
public void runBatch(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
apiAutomationService.run(request);
}
@PostMapping("/getReference")
public ReferenceDTO getReference(@RequestBody ApiScenarioRequest request) {
return apiAutomationService.getReference(request);

View File

@ -297,10 +297,6 @@ public class ApiAutomationService {
testPlan.setHashTree(new LinkedList<>());
HashTree jmeterTestPlanHashTree = new ListedHashTree();
String projectID = request.getProjectId();
// 批量执行的结果直接存储为报告
if (apiScenarios.size() > 1) {
request.setExecuteType(ExecuteType.Saved.name());
}
boolean isOne = true;
for (ApiScenarioWithBLOBs item : apiScenarios) {
MsThreadGroup group = new MsThreadGroup();

View File

@ -6,7 +6,7 @@
:show-create="false"/>
</template>
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select">
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select" v-loading="loading">
<el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="{row}">
@ -118,11 +118,14 @@
pageSize: 10,
total: 0,
reportId: "",
batchReportId: "",
content: {},
infoDb: false,
runVisible: false,
planVisible: false,
projectId: "",
runData: [],
report: {},
buttons: [
{
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
@ -145,12 +148,20 @@
this.search();
}
},
batchReportId() {
this.loading = true;
this.getReport();
}
},
computed: {
isNotRunning() {
return "Running" !== this.report.status;
}
},
methods: {
search() {
this.loading = true;
this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
@ -197,9 +208,33 @@
this.$success(this.$t("commons.save_success"));
});
},
getReport() {
if (this.batchReportId) {
let url = "/api/scenario/report/get/" + this.batchReportId;
this.$get(url, response => {
this.report = response.data || {};
if (response.data) {
if (this.isNotRunning) {
try {
this.content = JSON.parse(this.report.content);
} catch (e) {
throw e;
}
this.loading = false;
this.$success("批量执行成功,请到报告页面查看详情!");
} else {
setTimeout(this.getReport, 2000)
}
} else {
this.loading = false;
this.$error(this.$t('api_report.not_exist'));
}
});
}
},
handleBatchExecute() {
this.infoDb = false;
let url = "/api/automation/run";
let url = "/api/automation/run/batch";
let run = {};
let scenarioIds = this.selection;
run.id = getUUID();
@ -207,8 +242,8 @@
run.projectId = getCurrentProjectID();
this.$post(url, run, response => {
let data = response.data;
this.runVisible = true;
this.reportId = run.id;
this.runVisible = false;
this.batchReportId = run.id;
});
},
selectAllChange() {