fix(接口自动化): 修复接口测试-场景,引用接口用例数据会消失问题

This commit is contained in:
fit2-zhao 2021-07-01 11:33:29 +08:00 committed by fit2-zhao
parent c98fdc68b8
commit 7414d2bbe6
3 changed files with 117 additions and 113 deletions

View File

@ -30,6 +30,7 @@ public class ParallelExecTask<T> implements Callable<T> {
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(request.getTestPlanLoadId()); testPlanLoadCase.setId(request.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId); testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCase.setStatus("run");
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase); testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
return (T) reportId; return (T) reportId;

View File

@ -38,6 +38,7 @@ public class SerialExecTask<T> implements Callable<T> {
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
testPlanLoadCase.setId(request.getTestPlanLoadId()); testPlanLoadCase.setId(request.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId); testPlanLoadCase.setLoadReportId(reportId);
testPlanLoadCase.setStatus("run");
testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase); testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase);
LoadTestReportWithBLOBs report = null; LoadTestReportWithBLOBs report = null;
// 轮询查看报告状态最多200次防止死循环 // 轮询查看报告状态最多200次防止死循环

View File

@ -18,18 +18,18 @@
ref="table" ref="table"
> >
<ms-table-column <ms-table-column
prop="num" prop="num"
label="ID" label="ID"
width="80px" width="80px"
sortable=true> sortable=true>
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- &lt;!&ndash; 判断为只读用户的话不可点击ID进行编辑操作 &ndash;&gt;--> <!-- &lt;!&ndash; 判断为只读用户的话不可点击ID进行编辑操作 &ndash;&gt;-->
<!-- <span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>--> <!-- <span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>-->
<!-- <el-tooltip v-else content="编辑">--> <!-- <el-tooltip v-else content="编辑">-->
<!-- <a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>--> <!-- <a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>-->
<!-- </el-tooltip>--> <!-- </el-tooltip>-->
<!-- </template>--> <!-- </template>-->
</ms-table-column> </ms-table-column>
<ms-table-column prop="name" width="160px" :label="$t('test_track.case.name')"/> <ms-table-column prop="name" width="160px" :label="$t('test_track.case.name')"/>
@ -124,70 +124,70 @@ export default {
MsTable, MsTable,
MsTableColumn MsTableColumn
}, },
data() { data() {
return { return {
condition: {}, condition: {},
selectCase: {}, selectCase: {},
result: {}, result: {},
moduleId: "", moduleId: "",
typeArr: [ typeArr: [
{id: 'priority', name: this.$t('test_track.case.priority')}, {id: 'priority', name: this.$t('test_track.case.priority')},
], ],
priorityFilters: [ priorityFilters: [
{text: 'P0', value: 'P0'}, {text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'}, {text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'}, {text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'} {text: 'P3', value: 'P3'}
], ],
valueArr: { valueArr: {
priority: CASE_PRIORITY, priority: CASE_PRIORITY,
}, },
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
screenHeight: 'calc(100vh - 400px)',// screenHeight: 'calc(100vh - 400px)',//
tableData: [], tableData: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
environmentId: "" environmentId: ""
} }
},
props: {
currentProtocol: String,
selectNodeIds: Array,
visible: {
type: Boolean,
default: false,
}, },
props: { isApiListEnable: {
currentProtocol: String, type: Boolean,
selectNodeIds: Array, default: false,
visible: {
type: Boolean,
default: false,
},
isApiListEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
projectId: String,
planId: String,
isTestPlan: Boolean
}, },
created: function () { isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
projectId: String,
planId: String,
isTestPlan: Boolean
},
created: function () {
this.initTable();
},
watch: {
selectNodeIds() {
this.initTable(); this.initTable();
}, },
watch: { currentProtocol() {
selectNodeIds() { this.initTable();
this.initTable();
},
currentProtocol() {
this.initTable();
},
projectId() {
this.initTable();
}
}, },
projectId() {
this.initTable();
}
},
computed: { computed: {
selectRows() { selectRows() {
if (this.$refs.table) { if (this.$refs.table) {
@ -207,16 +207,18 @@ export default {
if (projectId != null && typeof projectId === 'string') { if (projectId != null && typeof projectId === 'string') {
this.condition.projectId = projectId; this.condition.projectId = projectId;
} else if (this.projectId != null) { } else if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
} }
let url = '/api/testcase/list/'; let url = '/api/testcase/list/';
if (this.isTestPlan) { if (this.isTestPlan) {
url = '/test/plan/api/case/relevance/list/'; url = '/test/plan/api/case/relevance/list/';
this.condition.planId = this.planId; this.condition.planId = this.planId;
} } else {
this.condition.ids = [];
}
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => { this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
@ -259,22 +261,22 @@ export default {
return path + "/" + this.currentPage + "/" + this.pageSize; return path + "/" + this.currentPage + "/" + this.pageSize;
}, },
handleTestCase(testCase) { handleTestCase(testCase) {
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => { this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => {
let api = response.data; let api = response.data;
let selectApi = api; let selectApi = api;
let request = {}; let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request; request = api.request;
} else { } else {
request = JSON.parse(api.request); request = JSON.parse(api.request);
} }
if (!request.hashTree) { if (!request.hashTree) {
request.hashTree = []; request.hashTree = [];
} }
selectApi.url = request.path; selectApi.url = request.path;
this.$refs.caseList.open(selectApi, testCase.id); this.$refs.caseList.open(selectApi, testCase.id);
}); });
}, },
setEnvironment(data) { setEnvironment(data) {
this.environmentId = data.id; this.environmentId = data.id;
}, },
@ -288,39 +290,39 @@ export default {
let sampleSelectRows = this.$refs.table.getSelectRows(); let sampleSelectRows = this.$refs.table.getSelectRows();
let batchParam = buildBatchParam(this); let batchParam = buildBatchParam(this);
let param = {}; let param = {};
if(batchParam.condition){ if (batchParam.condition) {
param = batchParam.condition; param = batchParam.condition;
param.projectId = batchParam.projectId; param.projectId = batchParam.projectId;
}else{ } else {
param = batchParam; param = batchParam;
} }
param.ids = Array.from(sampleSelectRows).map(row => row.id); param.ids = Array.from(sampleSelectRows).map(row => row.id);
return param; return param;
} }
}, },
} }
</script> </script>
<style scoped> <style scoped>
.operate-button > div { .operate-button > div {
display: inline-block; display: inline-block;
margin-left: 10px; margin-left: 10px;
} }
.request-method { .request-method {
padding: 0 5px; padding: 0 5px;
color: #1E90FF; color: #1E90FF;
} }
.api-el-tag { .api-el-tag {
color: white; color: white;
} }
.search-input { .search-input {
float: right; float: right;
width: 300px; width: 300px;
/*margin-bottom: 20px;*/ /*margin-bottom: 20px;*/
margin-right: 20px; margin-right: 20px;
} }
</style> </style>