测试报告缺陷数

This commit is contained in:
chenjianxing 2020-05-17 10:26:24 +08:00
parent bb081b451c
commit 5892cd3f29
2 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.track.service; package io.metersphere.track.service;
import com.alibaba.fastjson.JSON;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.TestCaseMapper; import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.TestCaseNodeMapper; import io.metersphere.base.mapper.TestCaseNodeMapper;
@ -296,12 +297,18 @@ public class TestPlanService {
moduleResult = new TestCaseReportModuleResultDTO(); moduleResult = new TestCaseReportModuleResultDTO();
moduleResult.setCaseCount(0); moduleResult.setCaseCount(0);
moduleResult.setPassCount(0); moduleResult.setPassCount(0);
moduleResult.setFlawCount(0);
moduleResult.setModuleId(rootNodeId); moduleResult.setModuleId(rootNodeId);
} }
moduleResult.setCaseCount(moduleResult.getCaseCount() + 1); moduleResult.setCaseCount(moduleResult.getCaseCount() + 1);
if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Pass.name())) { if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Pass.name())) {
moduleResult.setPassCount(moduleResult.getPassCount() + 1); moduleResult.setPassCount(moduleResult.getPassCount() + 1);
} }
if (StringUtils.isNotBlank(testCase.getFlaw())) {
if (JSON.parseObject(testCase.getFlaw()).getBoolean("hasFlaw")) {
moduleResult.setFlawCount(moduleResult.getFlawCount() + 1);
};
}
moduleResultMap.put(rootNodeId, moduleResult); moduleResultMap.put(rootNodeId, moduleResult);
return; return;
} }

View File

@ -137,19 +137,19 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row v-if="testCase.flaw">
<el-col :span="5" :offset="1"> <el-col :span="5" :offset="1">
<el-switch <el-switch
v-model="hasFlaw" v-model="testCase.flaw.hasFlaw"
@change="flawChange" @change="flawChange"
active-text="提缺陷"> active-text="提缺陷">
</el-switch> </el-switch>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="hasFlaw"> <el-row v-if="testCase.flaw && testCase.flaw.hasFlaw">
<el-col :span="20" :offset="1" class="step-edit"> <el-col :span="20" :offset="1" class="step-edit">
<ckeditor :editor="editor" v-model="testCase.flaw"/> <ckeditor :editor="editor" v-model="testCase.flaw.content"/>
</el-col> </el-col>
</el-row> </el-row>
@ -196,7 +196,6 @@
index: 0, index: 0,
testCases: [], testCases: [],
editor: ClassicEditor, editor: ClassicEditor,
hasFlaw: false
}; };
}, },
props: { props: {
@ -230,7 +229,7 @@
param.results.push(result); param.results.push(result);
}); });
param.results = JSON.stringify(param.results); param.results = JSON.stringify(param.results);
param.flaw = this.testCase.flaw; param.flaw = JSON.stringify(this.testCase.flaw);
this.$post('/test/plan/case/edit', param, () => { this.$post('/test/plan/case/edit', param, () => {
if (isContinuous) { if (isContinuous) {
this.updateTestCases(param); this.updateTestCases(param);
@ -257,6 +256,12 @@
Object.assign(item, testCase); Object.assign(item, testCase);
item.results = JSON.parse(item.results); item.results = JSON.parse(item.results);
item.steps = JSON.parse(item.steps); item.steps = JSON.parse(item.steps);
if (item.flaw) {
item.flaw = JSON.parse(item.flaw);
} else {
item.flaw = {};
item.flaw.hasFlaw = false;
}
item.steptResults = []; item.steptResults = [];
for (let i = 0; i < item.steps.length; i++){ for (let i = 0; i < item.steps.length; i++){
if(item.results[i]){ if(item.results[i]){
@ -269,11 +274,6 @@
}, },
openTestCaseEdit(testCase) { openTestCaseEdit(testCase) {
this.showDialog = true; this.showDialog = true;
if (testCase.flaw) {
this.hasFlaw = true;
} else {
this.hasFlaw = false;
}
this.initData(testCase); this.initData(testCase);
}, },
updateTestCases(testCase) { updateTestCases(testCase) {
@ -295,7 +295,7 @@
}); });
}, },
flawChange() { flawChange() {
if (this.hasFlaw && !this.testCase.flaw) { if (this.testCase.flaw.hasFlaw) {
let desc = this.addPLabel('[' + '操作步骤' + ']'); let desc = this.addPLabel('[' + '操作步骤' + ']');
let result = this.addPLabel('[' + '预期结果' + ']'); let result = this.addPLabel('[' + '预期结果' + ']');
let executeResult = this.addPLabel('[' + '实际结果' + ']'); let executeResult = this.addPLabel('[' + '实际结果' + ']');
@ -305,7 +305,7 @@
result += this.addPLabel(stepPrefix + (step.result == undefined ? '' : step.result)); result += this.addPLabel(stepPrefix + (step.result == undefined ? '' : step.result));
executeResult += this.addPLabel(stepPrefix + (step.executeResult == undefined ? '' : step.executeResult)); executeResult += this.addPLabel(stepPrefix + (step.executeResult == undefined ? '' : step.executeResult));
}); });
this.testCase.flaw = desc + this.addPLabel('') + result + this.addPLabel('') + executeResult + this.addPLabel(''); this.testCase.flaw.content = desc + this.addPLabel('') + result + this.addPLabel('') + executeResult + this.addPLabel('');
} }
}, },
addPLabel(str) { addPLabel(str) {