fix(测试计划): 修复测试计划执行报告看不到性能测试用例的问题

修复测试计划执行报告看不到性能测试用例的问题
This commit is contained in:
song-tianyang 2022-01-12 15:36:39 +08:00 committed by song-tianyang
parent c2b5ed5dfc
commit 4807af0c42
5 changed files with 55 additions and 50 deletions

View File

@ -11,6 +11,7 @@ import java.util.List;
public interface ExtTestPlanLoadCaseMapper { public interface ExtTestPlanLoadCaseMapper {
List<String> selectIdsNotInPlan(@Param("request") LoadCaseRequest request); List<String> selectIdsNotInPlan(@Param("request") LoadCaseRequest request);
List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request); List<TestPlanLoadCaseDTO> selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request);
List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request); List<TestPlanLoadCaseDTO> selectByIdIn(@Param("request") LoadCaseRequest request);
@ -26,7 +27,8 @@ public interface ExtTestPlanLoadCaseMapper {
List<PlanReportCaseDTO> selectForPlanReport(String planId); List<PlanReportCaseDTO> selectForPlanReport(String planId);
List<TestPlanLoadCaseDTO> getCases(@Param("planId") String planId, @Param("status") String status); List<TestPlanLoadCaseDTO> getCases(@Param("planId") String planId, @Param("status") String status);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids, @Param("planId") String planId, @Param("status") String status);
List<TestPlanLoadCaseDTO> getCasesByIds(@Param("ids") Collection<String> ids, @Param("reportIds") Collection<String> reportIds);
List<String> selectPlanIds(); List<String> selectPlanIds();

View File

@ -345,17 +345,18 @@
<select id="getCasesByIds" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO"> <select id="getCasesByIds" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id, select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,
tplc.status ,tplc.create_user, tplc.load_report_id ltr.status ,tplc.create_user, tplc.load_report_id,ltr.id AS reportId
from test_plan_load_case tplc from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id inner join load_test lt on tplc.load_case_id = lt.id
<if test="status != null"> inner join load_test_report ltr ON ltr.test_id = lt.id
and tplc.status = 'error' where tplc.id IN
</if>
where tplc.test_plan_id = #{planId}
and lt.id IN
<foreach collection="ids" item="id" separator="," open="(" close=")"> <foreach collection="ids" item="id" separator="," open="(" close=")">
#{id} #{id}
</foreach> </foreach>
and ltr.id IN
<foreach collection="reportIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select> </select>
<select id="selectPlanIds" resultType="java.lang.String"> <select id="selectPlanIds" resultType="java.lang.String">

View File

@ -408,8 +408,8 @@ public class TestPlanLoadCaseService {
return buildCases(cases); return buildCases(cases);
} }
public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, String planId, String status) { public List<TestPlanLoadCaseDTO> getAllCases(Collection<String> ids, Collection<String> reportIds) {
List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, planId, status); List<TestPlanLoadCaseDTO> cases = extTestPlanLoadCaseMapper.getCasesByIds(ids, reportIds);
return buildCases(cases); return buildCases(cases);
} }

View File

@ -1676,18 +1676,14 @@ public class TestPlanService {
} }
} }
public void buildLoadReport(TestPlanSimpleReportDTO report, JSONObject config, Map<String, String> loadCaseReportMap, String planId, boolean saveResponse) { public void buildLoadReport(TestPlanSimpleReportDTO report, JSONObject config, Map<String, String> loadCaseReportMap, boolean saveResponse) {
if (MapUtils.isEmpty(loadCaseReportMap)) { if (MapUtils.isEmpty(loadCaseReportMap)) {
return; return;
} }
if (checkReportConfig(config, "load")) { if (checkReportConfig(config, "load")) {
List<TestPlanLoadCaseDTO> allCases = null; List<TestPlanLoadCaseDTO> allCases = null;
if (checkReportConfig(config, "load", "all")) { if (checkReportConfig(config, "load", "all")) {
allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap.keySet(), planId, null); allCases = testPlanLoadCaseService.getAllCases(loadCaseReportMap.keySet(), loadCaseReportMap.values());
for (TestPlanLoadCaseDTO dto : allCases) {
String reportId = loadCaseReportMap.get(dto.getId());
dto.setReportId(reportId);
}
if (saveResponse) { if (saveResponse) {
buildLoadResponse(allCases); buildLoadResponse(allCases);
} }
@ -1718,7 +1714,7 @@ public class TestPlanService {
TestPlanSimpleReportDTO report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO); TestPlanSimpleReportDTO report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
buildFunctionalReport(report, config, testPlanReport.getTestPlanId()); buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
buildApiReport(report, config, testPlanExecuteReportDTO); buildApiReport(report, config, testPlanExecuteReportDTO);
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), testPlanReport.getTestPlanId(), false); buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
return report; return report;
} else { } else {
return null; return null;

View File

@ -39,7 +39,12 @@
<el-tag size="mini" v-else-if="row.status === 'run'"> <el-tag size="mini" v-else-if="row.status === 'run'">
{{ row.status }} {{ row.status }}
</el-tag> </el-tag>
<span v-else>-</span> <el-tag size="mini" v-else-if="row.status === 'Completed'">
{{ row.status }}
</el-tag>
<el-tag size="mini" v-else>
{{ row.status }}
</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -58,6 +63,7 @@ import {
getSharePlanLoadAllCase, getSharePlanLoadAllCase,
getSharePlanLoadFailureCase getSharePlanLoadFailureCase
} from "@/network/test-plan"; } from "@/network/test-plan";
export default { export default {
name: "LoadFailureResult", name: "LoadFailureResult",
components: {StatusTableItem, MethodTableItem, TypeTableItem}, components: {StatusTableItem, MethodTableItem, TypeTableItem},