feat: 测试计划-失败计划列表

This commit is contained in:
chenjianxing 2020-12-23 16:25:01 +08:00
parent ae42f30ca5
commit 4d7b794436
13 changed files with 463 additions and 19 deletions

View File

@ -18,7 +18,8 @@ public class ReportComponentFactory {
return new ReportResultAdvancedChartComponent(testPlan);
// return new ReportResultChartComponent(testPlan);
} else if (StringUtils.equals("4", componentId)) {
return new ReportFailureResultComponent(testPlan);
// return new ReportFailureResultComponent(testPlan);
return new ReportFailureAdvanceResultComponent(testPlan);
}
return null;
}

View File

@ -1,8 +1,12 @@
package io.metersphere.track.domain;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestPlanDTO;
import org.apache.commons.lang3.StringUtils;
public abstract class ReportComponent {
protected String componentId;
@ -15,4 +19,11 @@ public abstract class ReportComponent {
public abstract void readRecord(TestPlanCaseDTO testCase);
public abstract void afterBuild(TestCaseReportMetricDTO testCaseReportMetric);
public void readRecord(TestPlanApiCaseDTO testCase) {
}
public void readRecord(ApiScenarioDTO testCase) {
}
}

View File

@ -0,0 +1,55 @@
package io.metersphere.track.domain;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ScenarioStatus;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.track.dto.FailureTestCasesAdvanceDTO;
import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestPlanDTO;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class ReportFailureAdvanceResultComponent extends ReportComponent {
private List<TestPlanCaseDTO> functionalTestCases = new ArrayList<>();
private List<TestPlanApiCaseDTO> apiTestCases = new ArrayList<>();
private List<ApiScenarioDTO> scenarioTestCases = new ArrayList<>();
public ReportFailureAdvanceResultComponent(TestPlanDTO testPlan) {
super(testPlan);
componentId = "4";
}
@Override
public void readRecord(TestPlanCaseDTO testCase) {
if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Failure.name())) {
this.functionalTestCases.add(testCase);
}
}
@Override
public void readRecord(TestPlanApiCaseDTO testCase) {
if (StringUtils.equals(testCase.getExecResult(), "error")) {
this.apiTestCases.add(testCase);
}
}
@Override
public void readRecord(ApiScenarioDTO testCase) {
if (StringUtils.equals(testCase.getLastResult(), ScenarioStatus.Fail.name())) {
this.scenarioTestCases.add(testCase);
}
}
@Override
public void afterBuild(TestCaseReportMetricDTO testCaseReportMetric) {
FailureTestCasesAdvanceDTO failureTestCasesAdvanceDTO = new FailureTestCasesAdvanceDTO();
failureTestCasesAdvanceDTO.setFunctionalTestCases(functionalTestCases);
failureTestCasesAdvanceDTO.setApiTestCases(apiTestCases);
failureTestCasesAdvanceDTO.setScenarioTestCases(scenarioTestCases);
testCaseReportMetric.setFailureTestCases(failureTestCasesAdvanceDTO);
}
}

View File

@ -26,6 +26,6 @@ public class ReportFailureResultComponent extends ReportComponent {
@Override
public void afterBuild(TestCaseReportMetricDTO testCaseReportMetric) {
testCaseReportMetric.setFailureTestCases(failureTestCases);
// testCaseReportMetric.setFailureTestCases(failureTestCases);
}
}

View File

@ -1,8 +1,8 @@
package io.metersphere.track.domain;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ScenarioStatus;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.track.dto.*;
import org.apache.commons.lang3.StringUtils;
@ -23,8 +23,8 @@ public class ReportResultAdvancedChartComponent extends ReportComponent {
static {
apiResultMap.put("success", TestPlanTestCaseStatus.Pass.name());
apiResultMap.put("error", TestPlanTestCaseStatus.Failure.name());
scenarioResultMap.put(APITestStatus.Success.name(), TestPlanTestCaseStatus.Pass.name());
scenarioResultMap.put(APITestStatus.Error.name(), TestPlanTestCaseStatus.Failure.name());
scenarioResultMap.put(ScenarioStatus.Success.name(), TestPlanTestCaseStatus.Pass.name());
scenarioResultMap.put(ScenarioStatus.Fail.name(), TestPlanTestCaseStatus.Failure.name());
}
public ReportResultAdvancedChartComponent(TestPlanDTO testPlan) {
@ -37,10 +37,12 @@ public class ReportResultAdvancedChartComponent extends ReportComponent {
getStatusResultMap(functionalStatusResultMap, testCase.getStatus());
}
@Override
public void readRecord(TestPlanApiCaseDTO testCase) {
getStatusResultMap(apiStatusResultMap, apiResultMap.get(testCase.getExecResult()));
}
@Override
public void readRecord(ApiScenarioDTO testCase) {
getStatusResultMap(scenarioStatusResultMap, scenarioResultMap.get(testCase.getLastResult()));
}

View File

@ -0,0 +1,16 @@
package io.metersphere.track.dto;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class FailureTestCasesAdvanceDTO {
private List<TestPlanCaseDTO> functionalTestCases;
private List<TestPlanApiCaseDTO> apiTestCases;
private List<ApiScenarioDTO> scenarioTestCases;
}

View File

@ -13,7 +13,8 @@ public class TestCaseReportMetricDTO {
// private List<TestCaseReportStatusResultDTO> executeResult;
private TestCaseReportAdvanceStatusResultDTO executeResult;
private List<TestCaseReportModuleResultDTO> moduleExecuteResult;
private List<TestPlanCaseDTO> failureTestCases;
private FailureTestCasesAdvanceDTO failureTestCases;
// private List<TestPlanCaseDTO> failureTestCases;
private List<Issues> Issues;
private List<String> executors;
private String principal;

View File

@ -26,7 +26,7 @@ import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.SystemParameterService;
import io.metersphere.track.Factory.ReportComponentFactory;
import io.metersphere.track.domain.ReportComponent;
import io.metersphere.track.domain.ReportResultAdvancedChartComponent;
import io.metersphere.track.dto.TestCaseReportMetricDTO;
import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestPlanDTO;
@ -623,13 +623,9 @@ public class TestPlanService {
ApiTestCaseRequest request = new ApiTestCaseRequest();
request.setPlanId(planId);
List<TestPlanApiCaseDTO> apiCaseDTOS = testPlanApiCaseService.list(request);
ReportResultAdvancedChartComponent chartComponent = null;
for (TestPlanApiCaseDTO item : apiCaseDTOS) {
for (ReportComponent component : components) {
if (component instanceof ReportResultAdvancedChartComponent) {
chartComponent = (ReportResultAdvancedChartComponent) component;
chartComponent.readRecord(item);
}
component.readRecord(item);
}
}
}
@ -638,13 +634,9 @@ public class TestPlanService {
TestPlanScenarioRequest request = new TestPlanScenarioRequest();
request.setPlanId(planId);
List<ApiScenarioDTO> scenarioDTOS = testPlanScenarioCaseService.list(request);
ReportResultAdvancedChartComponent chartComponent = null;
for (ApiScenarioDTO item : scenarioDTOS) {
for (ReportComponent component : components) {
if (component instanceof ReportResultAdvancedChartComponent) {
chartComponent = (ReportResultAdvancedChartComponent) component;
chartComponent.readRecord(item);
}
component.readRecord(item);
}
}
}

View File

@ -0,0 +1,104 @@
<template>
<common-component :title="$t('test_track.plan_view.failure_case')">
<template>
<functional-failure-cases-list :functional-test-cases="failureTestCases.functionalTestCases"/>
<api-failure-cases-list :api-test-cases="failureTestCases.apiTestCases"/>
<scenario-failure-cases-list :scenario-test-cases="failureTestCases.scenarioTestCases"/>
</template>
</common-component>
</template>
<script>
import CommonComponent from "./CommonComponent";
import PriorityTableItem from "../../../../../common/tableItems/planview/PriorityTableItem";
import TypeTableItem from "../../../../../common/tableItems/planview/TypeTableItem";
import MethodTableItem from "../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../common/tableItems/planview/StatusTableItem";
import {hub} from "@/business/components/track/plan/event-bus";
import FunctionalFailureCasesList from "./component/FunctionalFailureCasesList";
import ApiFailureCasesList from "./component/ApiFailureCasesList";
import ScenarioFailureCasesList from "./component/ScenarioFailureCasesList";
export default {
name: "FailureResultAdvanceComponent",
components: {
ScenarioFailureCasesList,
ApiFailureCasesList,
FunctionalFailureCasesList,
StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem, CommonComponent},
props: {
failureTestCases: {
type: Object,
default() {
return {
functionalTestCases: [
{
name: 'testCase1',
priority: 'P1',
type: 'api',
method: 'auto',
nodePath: '/module1/module2',
executorName: "Tom",
status: "Failure",
updateTime: new Date(),
},
{
name: 'testCase2',
priority: 'P0',
type: 'functional',
method: 'manual',
nodePath: '/module1',
executorName: "Micheal",
status: "Failure",
updateTime: new Date()
}
],
apiTestCases: [
{
name: 'testCase3',
priority: 'P2',
path: '/module1/module2',
createUser: "Tom",
lastResult: "Failure",
updateTime: new Date(),
}
],
scenarioTestCases: [
{
name: 'testCase4',
level: 'P3',
modulePath: '/module1/module2',
stepTotal: 10,
passRate: '80%',
userId: "Tom",
lastResult: "Failure",
updateTime: new Date(),
}
]
}
}
}
},
methods: {
goFailureTestCase(row) {
hub.$emit("openFailureTestCase", row);
}
}
}
</script>
<style scoped>
/deep/ .failure-cases-list-header {
font-size: 14px;
font-weight: 600;
margin-bottom: 10px;
}
.failure-cases-list {
margin-bottom: 30px;
}
</style>

View File

@ -7,7 +7,8 @@
<test-result-component v-if="preview.id == 2"/>
<!--<test-result-chart-component v-if="preview.id == 3"/>-->
<test-result-advance-chart-component v-if="preview.id == 3"/>
<failure-result-component v-if="preview.id == 4"/>
<!--<failure-result-component v-if="preview.id == 4"/>-->
<failure-result-advance-component v-if="preview.id == 4"/>
<defect-list-component v-if="preview.id == 5"/>
<rich-text-component :preview="preview" v-if="preview.type != 'system'"/>
</div>
@ -18,7 +19,8 @@
<test-result-component id="testResultComponent" :test-results="metric.moduleExecuteResult" v-if="preview.id == 2"/>
<!--<test-result-chart-component id="resultChartComponent" :execute-result="metric.executeResult" v-if="preview.id == 3"/>-->
<test-result-advance-chart-component id="resultChartComponent" :execute-result="metric.executeResult" v-if="preview.id == 3"/>
<failure-result-component id="failureResultComponent" :failure-test-cases="metric.failureTestCases" v-if="preview.id == 4"/>
<!--<failure-result-component id="failureResultComponent" :failure-test-cases="metric.failureTestCases" v-if="preview.id == 4"/>-->
<failure-result-advance-component id="failureResultComponent" :failure-test-cases="metric.failureTestCases" v-if="preview.id == 4"/>
<defect-list-component id="defectListComponent" :defect-list="metric.issues" v-if="preview.id == 5"/>
<rich-text-component id="richTextComponent" :is-report-view="isReportView" :preview="preview" v-if="preview.type != 'system'"/>
</div>
@ -35,10 +37,12 @@
import DefectListComponent from "./DefectListComponent";
import html2canvas from 'html2canvas';
import TestResultAdvanceChartComponent from "./TestResultAdvanceChartComponent";
import FailureResultAdvanceComponent from "./FailureResultAdvanceComponent";
export default {
name: "TemplateComponent",
components: {
FailureResultAdvanceComponent,
TestResultAdvanceChartComponent,
FailureResultComponent,DefectListComponent,
RichTextComponent, TestResultChartComponent, TestResultComponent, BaseInfoComponent},

View File

@ -0,0 +1,73 @@
<template>
<div class="failure-cases-list">
<div class="failure-cases-list-header">
接口测试用例
</div>
<el-table
row-key="id"
@row-click="goFailureTestCase"
:data="apiTestCases">
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
<el-table-column
prop="priority"
column-key="priority"
:label="$t('test_track.case.priority')"
show-overflow-tooltip>
<template v-slot:default="scope">
<priority-table-item :value="scope.row.priority"/>
</template>
</el-table-column>
<el-table-column
prop="path"
:label="$t('test_track.case.module')"
show-overflow-tooltip/>
<el-table-column
prop="createUser"
:label="'创建人'"
show-overflow-tooltip/>
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')">
<template v-slot:default="{row}">
<ms-tag type="danger" :content="$t('test_track.plan_view.failure')"/>
</template>
</el-table-column>
<el-table-column
width="160"
:label="$t('api_test.definition.api_last_time')"
prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTableItem";
import PriorityTableItem from "../../../../../../common/tableItems/planview/PriorityTableItem";
import MsTag from "../../../../../../../common/components/MsTag";
export default {
name: "ApiFailureCasesList",
components: {MsTag, PriorityTableItem, TypeTableItem, MethodTableItem, StatusTableItem},
props: ['apiTestCases'],
methods: {
goFailureTestCase(row) {
this.$emit("openFailureTestCase", row);
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,108 @@
<template>
<div class="failure-cases-list">
<div class="failure-cases-list-header">
功能测试用例
</div>
<el-table
row-key="id"
@row-click="goFailureTestCase"
:data="functionalTestCases">
<el-table-column
prop="num"
:label="$t('commons.id')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="name"
:label="$t('commons.name')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="priority"
column-key="priority"
:label="$t('test_track.case.priority')">
<template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/>
</template>
</el-table-column>
<el-table-column
prop="type"
column-key="type"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column
prop="method"
column-key="method"
:label="$t('test_track.case.method')"
show-overflow-tooltip>
<template v-slot:default="scope">
<method-table-item :value="scope.row.method"/>
</template>
</el-table-column>
<el-table-column
prop="nodePath"
:label="$t('test_track.case.module')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="projectName"
:label="$t('test_track.case.project_name')"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="executorName"
:label="$t('test_track.plan_view.executor')">
</el-table-column>
<el-table-column
prop="status"
column-key="status"
:label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope">
<status-table-item :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column
prop="updateTime"
:label="$t('api_test.automation.update_time')"
show-overflow-tooltip>
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTableItem";
import PriorityTableItem from "../../../../../../common/tableItems/planview/PriorityTableItem";
export default {
name: "FunctionalFailureCasesList",
components: {PriorityTableItem, TypeTableItem, MethodTableItem, StatusTableItem},
props: ['functionalTestCases'],
methods: {
goFailureTestCase(row) {
this.$emit("openFailureTestCase", row);
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,77 @@
<template>
<div class="failure-cases-list">
<div class="failure-cases-list-header">
场景测试用例
</div>
<el-table
row-key="id"
@row-click="goFailureTestCase"
:data="scenarioTestCases">
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')" show-overflow-tooltip/>
<el-table-column prop="level" :label="$t('api_test.automation.case_level')"
show-overflow-tooltip>
<template v-slot:default="scope">
<priority-table-item :value="scope.row.level" ref="priority"/>
</template>
</el-table-column>
<el-table-column prop="tags" :label="$t('api_test.automation.tag')" width="200px">
<template v-slot:default="scope">
<div v-for="(itemName,index) in scope.row.tags" :key="index">
<ms-tag type="success" effect="plain" :content="itemName"/>
</div>
</template>
</el-table-column>
<el-table-column
prop="modulePath"
:label="$t('test_track.case.module')"
show-overflow-tooltip>
</el-table-column>
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" show-overflow-tooltip/>
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')" show-overflow-tooltip/>
<el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/>
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')">
<template v-slot:default="{row}">
<ms-tag type="danger" :content="$t('test_track.plan_view.failure')"/>
</template>
</el-table-column>
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" width="180">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTableItem";
import PriorityTableItem from "../../../../../../common/tableItems/planview/PriorityTableItem";
import MsTag from "../../../../../../../common/components/MsTag";
export default {
name: "ScenarioFailureCasesList",
components: {MsTag, PriorityTableItem, TypeTableItem, MethodTableItem, StatusTableItem},
props: ['scenarioTestCases'],
methods: {
goFailureTestCase(row) {
this.$emit("openFailureTestCase", row);
}
}
}
</script>
<style scoped>
</style>