feat(测试计划): 测试计划组报告总结一键生成内容新增子计划信息
--task=1016926 --user=王旭 【Bug转需求】[测试计划]github#33641生成报告统计的缺陷个数错误,应该用缺陷条数,而不是用关联用例加和-后端 https://www.tapd.cn/55049933/s/1603574
This commit is contained in:
parent
6313afe427
commit
fcee7fb217
|
@ -1,11 +1,14 @@
|
||||||
package io.metersphere.plan.dto.response;
|
package io.metersphere.plan.dto.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.metersphere.plan.dto.CaseCount;
|
import io.metersphere.plan.dto.CaseCount;
|
||||||
import io.metersphere.system.serializer.CustomRateSerializer;
|
import io.metersphere.system.serializer.CustomRateSerializer;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TestPlanReportDetailResponse {
|
public class TestPlanReportDetailResponse {
|
||||||
|
|
||||||
|
@ -91,4 +94,8 @@ public class TestPlanReportDetailResponse {
|
||||||
*/
|
*/
|
||||||
@Schema(description = "报告是否默认布局")
|
@Schema(description = "报告是否默认布局")
|
||||||
private Boolean defaultLayout;
|
private Boolean defaultLayout;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
@Schema(description = "计划组子计划数据信息")
|
||||||
|
private List<TestPlanReportDetailResponse> children;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,30 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countBug" resultType="io.metersphere.plan.dto.ReportBugSumDTO">
|
<select id="countBug" resultType="io.metersphere.plan.dto.ReportBugSumDTO">
|
||||||
select 'FUNCTIONAL' as caseType, ifnull(sum(tprfc.function_case_bug_count), 0) as bugCount from test_plan_report_function_case tprfc
|
SELECT
|
||||||
where tprfc.test_plan_report_id = #{id}
|
'FUNCTIONAL' AS caseType,
|
||||||
union
|
count( DISTINCT brc.bug_id ) AS bugCount
|
||||||
select 'API' as caseType, ifnull(sum(tprac.api_case_bug_count), 0) as bugCount from test_plan_report_api_case tprac
|
FROM
|
||||||
where tprac.test_plan_report_id = #{id}
|
bug_relation_case brc
|
||||||
union
|
INNER JOIN test_plan_report_function_case tprfc ON brc.test_plan_case_id = tprfc.test_plan_function_case_id
|
||||||
select 'SCENARIO' as caseType, ifnull(sum(tpras.api_scenario_bug_count), 0) as bugCount from test_plan_report_api_scenario tpras
|
WHERE
|
||||||
where tpras.test_plan_report_id = #{id}
|
tprfc.test_plan_report_id = #{id} UNION
|
||||||
|
SELECT
|
||||||
|
'API' AS caseType,
|
||||||
|
count( DISTINCT brc.bug_id ) AS bugCount
|
||||||
|
FROM
|
||||||
|
bug_relation_case brc
|
||||||
|
INNER JOIN test_plan_report_api_case tprac ON brc.test_plan_case_id = tprac.test_plan_api_case_id
|
||||||
|
WHERE
|
||||||
|
tprac.test_plan_report_id = #{id} UNION
|
||||||
|
SELECT
|
||||||
|
'SCENARIO' AS caseType,
|
||||||
|
count( DISTINCT brc.bug_id ) AS bugCount
|
||||||
|
FROM
|
||||||
|
bug_relation_case brc
|
||||||
|
INNER JOIN test_plan_report_api_scenario tpras ON brc.test_plan_case_id = tpras.test_plan_api_scenario_id
|
||||||
|
WHERE
|
||||||
|
tpras.test_plan_report_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countPlanBug" resultType="io.metersphere.plan.dto.ReportBugCountDTO">
|
<select id="countPlanBug" resultType="io.metersphere.plan.dto.ReportBugCountDTO">
|
||||||
|
|
|
@ -67,4 +67,6 @@ public interface ExtTestPlanReportMapper {
|
||||||
List<ReportDTO> getReportsByIds(@Param("ids") List<String> ids);
|
List<ReportDTO> getReportsByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
void deleteGroupReport(@Param("id") String id);
|
void deleteGroupReport(@Param("id") String id);
|
||||||
|
|
||||||
|
List<TestPlanReport> getChildrenReport(@Param("reportId") String reportId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
tpr.result_status,
|
tpr.result_status,
|
||||||
tpr.pass_rate,
|
tpr.pass_rate,
|
||||||
tpr.pass_threshold,
|
tpr.pass_threshold,
|
||||||
(tprs.functional_case_count + tprs.api_case_count + tprs.api_scenario_count + tprs.bug_count) as caseTotal,
|
(tprs.functional_case_count + tprs.api_case_count + tprs.api_scenario_count) as caseTotal,
|
||||||
tpr.create_time,
|
tpr.create_time,
|
||||||
tpr.deleted
|
tpr.deleted
|
||||||
|
|
||||||
|
@ -471,4 +471,9 @@
|
||||||
</when>
|
</when>
|
||||||
</choose>
|
</choose>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getChildrenReport" resultType="io.metersphere.plan.domain.TestPlanReport">
|
||||||
|
select id from test_plan_report where parent_id = #{reportId} and id != #{reportId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -780,6 +780,17 @@ public class TestPlanReportService {
|
||||||
planReportDetail.setApiCaseCount(reportSummary.getApiExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getApiExecuteResult()), CaseCount.class));
|
planReportDetail.setApiCaseCount(reportSummary.getApiExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getApiExecuteResult()), CaseCount.class));
|
||||||
planReportDetail.setApiScenarioCount(reportSummary.getScenarioExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getScenarioExecuteResult()), CaseCount.class));
|
planReportDetail.setApiScenarioCount(reportSummary.getScenarioExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getScenarioExecuteResult()), CaseCount.class));
|
||||||
planReportDetail.setExecuteCount(reportSummary.getExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getExecuteResult()), CaseCount.class));
|
planReportDetail.setExecuteCount(reportSummary.getExecuteResult() == null ? CaseCount.builder().build() : JSON.parseObject(new String(reportSummary.getExecuteResult()), CaseCount.class));
|
||||||
|
|
||||||
|
//如果是计划组,需要获取每条子计划数据
|
||||||
|
List<TestPlanReport> testPlans = extTestPlanReportMapper.getChildrenReport(reportId);
|
||||||
|
if (CollectionUtils.isNotEmpty(testPlans)) {
|
||||||
|
List<TestPlanReportDetailResponse> children = new ArrayList<>();
|
||||||
|
testPlans.forEach(item -> {
|
||||||
|
TestPlanReportDetailResponse report = getReport(item.getId());
|
||||||
|
children.add(report);
|
||||||
|
});
|
||||||
|
planReportDetail.setChildren(children);
|
||||||
|
}
|
||||||
return planReportDetail;
|
return planReportDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1253,6 +1264,7 @@ public class TestPlanReportService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取测试点集合
|
* 获取测试点集合
|
||||||
|
*
|
||||||
* @param collectionIds 测试点ID集合
|
* @param collectionIds 测试点ID集合
|
||||||
* @return 测试点集合
|
* @return 测试点集合
|
||||||
*/
|
*/
|
||||||
|
@ -1278,6 +1290,7 @@ public class TestPlanReportService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划报告测试集列表
|
* 计划报告测试集列表
|
||||||
|
*
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
* @param caseType 用例类型
|
* @param caseType 用例类型
|
||||||
* @return 测试集列表
|
* @return 测试集列表
|
||||||
|
@ -1285,9 +1298,11 @@ public class TestPlanReportService {
|
||||||
public List<TestPlanReportDetailCollectionResponse> listReportCollection(TestPlanReportDetailPageRequest request, String caseType) {
|
public List<TestPlanReportDetailCollectionResponse> listReportCollection(TestPlanReportDetailPageRequest request, String caseType) {
|
||||||
List<TestPlanReportDetailCollectionResponse> collections;
|
List<TestPlanReportDetailCollectionResponse> collections;
|
||||||
switch (caseType) {
|
switch (caseType) {
|
||||||
case CollectionQueryType.FUNCTIONAL -> collections = extTestPlanReportFunctionalCaseMapper.listCollection(request);
|
case CollectionQueryType.FUNCTIONAL ->
|
||||||
|
collections = extTestPlanReportFunctionalCaseMapper.listCollection(request);
|
||||||
case CollectionQueryType.API -> collections = extTestPlanReportApiCaseMapper.listCollection(request);
|
case CollectionQueryType.API -> collections = extTestPlanReportApiCaseMapper.listCollection(request);
|
||||||
case CollectionQueryType.SCENARIO -> collections = extTestPlanReportApiScenarioMapper.listCollection(request);
|
case CollectionQueryType.SCENARIO ->
|
||||||
|
collections = extTestPlanReportApiScenarioMapper.listCollection(request);
|
||||||
default -> collections = new ArrayList<>();
|
default -> collections = new ArrayList<>();
|
||||||
}
|
}
|
||||||
collections.sort(Comparator.comparing(TestPlanReportDetailCollectionResponse::getPos));
|
collections.sort(Comparator.comparing(TestPlanReportDetailCollectionResponse::getPos));
|
||||||
|
|
|
@ -296,6 +296,7 @@ public class TestPlanReportControllerTests extends BaseTest {
|
||||||
@Order(14)
|
@Order(14)
|
||||||
void testGetReportSuccess() throws Exception {
|
void testGetReportSuccess() throws Exception {
|
||||||
this.requestGet(GET_PLAN_REPORT + "/" + GEN_REPORT_ID);
|
this.requestGet(GET_PLAN_REPORT + "/" + GEN_REPORT_ID);
|
||||||
|
this.requestGet(GET_PLAN_REPORT + "/" + "test-plan-report-id-5");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue