feat(测试计划): 执行用例时显示关联测试

This commit is contained in:
shiziyuan9527 2021-03-22 15:44:00 +08:00
parent bb4f30a9a1
commit fa0a57a6af
7 changed files with 101 additions and 9 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.track.dto.TestCaseReportStatusResultDTO; import io.metersphere.track.dto.TestCaseReportStatusResultDTO;
import io.metersphere.track.dto.TestCaseTestDTO;
import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -47,4 +48,6 @@ public interface ExtTestPlanTestCaseMapper {
List<String> getExecResultByPlanId(String planId); List<String> getExecResultByPlanId(String planId);
List<TestPlanCaseDTO> listForMinder(@Param("planId") String planId); List<TestPlanCaseDTO> listForMinder(@Param("planId") String planId);
List<TestCaseTestDTO> listTestCaseTest(@Param("caseId") String caseId);
} }

View File

@ -421,6 +421,9 @@
pc.plan_id = #{planId} pc.plan_id = #{planId}
</where> </where>
</select> </select>
<select id="listTestCaseTest" resultType="io.metersphere.track.dto.TestCaseTestDTO">
select * from test_case_test where test_case_id = #{caseId};
</select>
<update id="updateTestCaseStates" parameterType="java.lang.String"> <update id="updateTestCaseStates" parameterType="java.lang.String">
update test_plan_test_case update test_plan_test_case

View File

@ -0,0 +1,11 @@
package io.metersphere.track.dto;
import io.metersphere.base.domain.TestCaseTest;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestCaseTestDTO extends TestCaseTest {
private String testName;
}

View File

@ -3,6 +3,8 @@ package io.metersphere.track.dto;
import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.base.domain.TestCaseWithBLOBs;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Getter @Getter
@Setter @Setter
@ -18,4 +20,6 @@ public class TestPlanCaseDTO extends TestCaseWithBLOBs {
private String reportId; private String reportId;
private String model; private String model;
private String projectName; private String projectName;
private List<TestCaseTestDTO> list;
} }

View File

@ -1,11 +1,8 @@
package io.metersphere.track.service; package io.metersphere.track.service;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestPlan; import io.metersphere.base.domain.*;
import io.metersphere.base.domain.TestPlanTestCaseExample; import io.metersphere.base.mapper.*;
import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs;
import io.metersphere.base.domain.User;
import io.metersphere.base.mapper.TestPlanTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
@ -14,6 +11,7 @@ import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
import io.metersphere.track.dto.TestCaseTestDTO;
import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest; import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
@ -42,6 +40,14 @@ public class TestPlanTestCaseService {
@Resource @Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper; ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
@Resource
private TestCaseTestMapper testCaseTestMapper;
@Resource
private LoadTestMapper loadTestMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) { public List<TestPlanCaseDTO> list(QueryTestPlanCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -134,7 +140,40 @@ public class TestPlanTestCaseService {
} }
public TestPlanCaseDTO get(String testplanTestCaseId) { public TestPlanCaseDTO get(String testplanTestCaseId) {
return extTestPlanTestCaseMapper.get(testplanTestCaseId); TestPlanCaseDTO testPlanCaseDTO = extTestPlanTestCaseMapper.get(testplanTestCaseId);
List<TestCaseTestDTO> testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testPlanCaseDTO.getCaseId());
testCaseTestDTOS.forEach(dto -> {
setTestName(dto);
});
testPlanCaseDTO.setList(testCaseTestDTOS);
return testPlanCaseDTO;
}
private void setTestName(TestCaseTestDTO dto) {
String type = dto.getTestType();
String id = dto.getTestId();
switch (type) {
case "performance":
LoadTest loadTest = loadTestMapper.selectByPrimaryKey(id);
if (loadTest != null) {
dto.setTestName(loadTest.getName());
}
break;
case "testcase":
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (apiTestCaseWithBLOBs != null) {
dto.setTestName(apiTestCaseWithBLOBs.getName());
}
break;
case "automation":
ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id);
if (apiScenarioWithBLOBs != null) {
dto.setTestName(apiScenarioWithBLOBs.getName());
}
break;
default:
break;
}
} }
public void deleteTestCaseBath(TestPlanCaseBatchRequest request) { public void deleteTestCaseBath(TestPlanCaseBatchRequest request) {

View File

@ -44,12 +44,12 @@ export default {
component: () => import('@/business/components/api/report/ApiReportView'), component: () => import('@/business/components/api/report/ApiReportView'),
}, },
{ {
path: "definition", path: "definition/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiDefinition", name: "ApiDefinition",
component: () => import('@/business/components/api/definition/ApiDefinition'), component: () => import('@/business/components/api/definition/ApiDefinition'),
}, },
{ {
path: "automation", path: "automation/:redirectID?/:dataType?/:dataSelectRange?",
name: "ApiAutomation", name: "ApiAutomation",
component: () => import('@/business/components/api/automation/ApiAutomation'), component: () => import('@/business/components/api/automation/ApiAutomation'),
}, },

View File

@ -85,6 +85,15 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :offset="1">
<span class="cast_label">关联测试</span>
<span v-for="(item,index) in testCase.list" :key="index">
<el-button @click="openTest(item)" type="text" style="margin-left: 7px;">{{ item.testName }}</el-button>
</span>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :offset="1"> <el-col :offset="1">
<span class="cast_label">{{ $t('test_track.case.prerequisite') }}</span> <span class="cast_label">{{ $t('test_track.case.prerequisite') }}</span>
@ -351,7 +360,7 @@ import ApiTestDetail from "../test/ApiTestDetail";
import ApiTestResult from "../test/ApiTestResult"; import ApiTestResult from "../test/ApiTestResult";
import PerformanceTestDetail from "../test/PerformanceTestDetail"; import PerformanceTestDetail from "../test/PerformanceTestDetail";
import PerformanceTestResult from "../test/PerformanceTestResult"; import PerformanceTestResult from "../test/PerformanceTestResult";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {getUUID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment"; import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment";
import CaseComment from "@/business/components/track/case/components/CaseComment"; import CaseComment from "@/business/components/track/case/components/CaseComment";
import MsPreviousNextButton from "../../../../../common/components/MsPreviousNextButton"; import MsPreviousNextButton from "../../../../../common/components/MsPreviousNextButton";
@ -559,6 +568,29 @@ export default {
} }
}); });
}, },
openTest(item) {
const type = item.testType;
const id = item.testId;
switch (type) {
case "performance": {
let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id,
})
window.open(performanceData.href, '_blank');
break;
}
case "testcase": {
let caseData = this.$router.resolve({name:'ApiDefinition',params:{redirectID:getUUID(),dataType:"apiTestCase",dataSelectRange:'single:'+id}});
window.open(caseData.href, '_blank');
break;
}
case "automation": {
let automationData = this.$router.resolve({name:'ApiAutomation',params:{redirectID:getUUID(),dataType:"scenario",dataSelectRange:'edit:'+id}});
window.open(automationData.href, '_blank');
break;
}
}
},
getRelatedTest() { getRelatedTest() {
if (this.testCase.method === 'auto' && this.testCase.testId && this.testCase.testId !== 'other') { if (this.testCase.method === 'auto' && this.testCase.testId && this.testCase.testId !== 'other') {
this.$get('/' + this.testCase.type + '/get/' + this.testCase.testId, response => { this.$get('/' + this.testCase.type + '/get/' + this.testCase.testId, response => {