fix(UI 自动化): 导出测试报告,无法查看ui用例执行结果

--bug=1015452 --user=张大海 【测试计划】导出测试报告,无法查看ui用例执行结果 https://www.tapd.cn/55049933/s/1215877
This commit is contained in:
zhangdahai112 2022-08-01 10:34:50 +08:00 committed by zhangdahai112
parent 134e781f7c
commit 41c3b23384
5 changed files with 40 additions and 7 deletions

View File

@ -59,5 +59,7 @@ public class TestPlanReportContentWithBLOBs extends TestPlanReportContent implem
private String uiAllCases; private String uiAllCases;
private String uiFailureCases;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -37,6 +37,7 @@
<result column="ui_result" jdbcType="LONGVARCHAR" property="uiResult" /> <result column="ui_result" jdbcType="LONGVARCHAR" property="uiResult" />
<result column="api_base_count" jdbcType="LONGVARCHAR" property="apiBaseCount" /> <result column="api_base_count" jdbcType="LONGVARCHAR" property="apiBaseCount" />
<result column="ui_all_cases" jdbcType="LONGVARCHAR" property="uiAllCases" /> <result column="ui_all_cases" jdbcType="LONGVARCHAR" property="uiAllCases" />
<result column="ui_failure_cases" jdbcType="LONGVARCHAR" property="uiFailureCases" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -106,7 +107,7 @@
load_all_Cases, load_failure_cases, plan_scenario_report_struct, plan_api_case_report_struct, load_all_Cases, load_failure_cases, plan_scenario_report_struct, plan_api_case_report_struct,
plan_load_case_report_struct, error_report_cases, error_report_scenarios, un_execute_cases, plan_load_case_report_struct, error_report_cases, error_report_scenarios, un_execute_cases,
un_execute_scenarios, plan_ui_scenario_report_struct, ui_result, api_base_count, un_execute_scenarios, plan_ui_scenario_report_struct, ui_result, api_base_count,
ui_all_cases ui_all_cases, ui_failure_cases
</sql> </sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultMap="ResultMapWithBLOBs"> <select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultMap="ResultMapWithBLOBs">
select select
@ -169,8 +170,8 @@
plan_load_case_report_struct, error_report_cases, plan_load_case_report_struct, error_report_cases,
error_report_scenarios, un_execute_cases, error_report_scenarios, un_execute_cases,
un_execute_scenarios, plan_ui_scenario_report_struct, un_execute_scenarios, plan_ui_scenario_report_struct,
ui_result, api_base_count, ui_all_cases ui_result, api_base_count, ui_all_cases,
) ui_failure_cases)
values (#{id,jdbcType=VARCHAR}, #{testPlanReportId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, values (#{id,jdbcType=VARCHAR}, #{testPlanReportId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{caseCount,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{executeRate,jdbcType=DOUBLE}, #{caseCount,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{executeRate,jdbcType=DOUBLE},
#{passRate,jdbcType=DOUBLE}, #{isThirdPartIssue,jdbcType=BIT}, #{config,jdbcType=LONGVARCHAR}, #{passRate,jdbcType=DOUBLE}, #{isThirdPartIssue,jdbcType=BIT}, #{config,jdbcType=LONGVARCHAR},
@ -183,8 +184,8 @@
#{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, #{errorReportCases,jdbcType=LONGVARCHAR}, #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, #{errorReportCases,jdbcType=LONGVARCHAR},
#{errorReportScenarios,jdbcType=LONGVARCHAR}, #{unExecuteCases,jdbcType=LONGVARCHAR}, #{errorReportScenarios,jdbcType=LONGVARCHAR}, #{unExecuteCases,jdbcType=LONGVARCHAR},
#{unExecuteScenarios,jdbcType=LONGVARCHAR}, #{planUiScenarioReportStruct,jdbcType=LONGVARCHAR}, #{unExecuteScenarios,jdbcType=LONGVARCHAR}, #{planUiScenarioReportStruct,jdbcType=LONGVARCHAR},
#{uiResult,jdbcType=LONGVARCHAR}, #{apiBaseCount,jdbcType=LONGVARCHAR}, #{uiAllCases,jdbcType=LONGVARCHAR} #{uiResult,jdbcType=LONGVARCHAR}, #{apiBaseCount,jdbcType=LONGVARCHAR}, #{uiAllCases,jdbcType=LONGVARCHAR},
) #{uiFailureCases,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReportContentWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReportContentWithBLOBs">
insert into test_plan_report_content insert into test_plan_report_content
@ -288,6 +289,9 @@
<if test="uiAllCases != null"> <if test="uiAllCases != null">
ui_all_cases, ui_all_cases,
</if> </if>
<if test="uiFailureCases != null">
ui_failure_cases,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -389,6 +393,9 @@
<if test="uiAllCases != null"> <if test="uiAllCases != null">
#{uiAllCases,jdbcType=LONGVARCHAR}, #{uiAllCases,jdbcType=LONGVARCHAR},
</if> </if>
<if test="uiFailureCases != null">
#{uiFailureCases,jdbcType=LONGVARCHAR},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultType="java.lang.Long">
@ -499,6 +506,9 @@
<if test="record.uiAllCases != null"> <if test="record.uiAllCases != null">
ui_all_cases = #{record.uiAllCases,jdbcType=LONGVARCHAR}, ui_all_cases = #{record.uiAllCases,jdbcType=LONGVARCHAR},
</if> </if>
<if test="record.uiFailureCases != null">
ui_failure_cases = #{record.uiFailureCases,jdbcType=LONGVARCHAR},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -538,7 +548,8 @@
plan_ui_scenario_report_struct = #{record.planUiScenarioReportStruct,jdbcType=LONGVARCHAR}, plan_ui_scenario_report_struct = #{record.planUiScenarioReportStruct,jdbcType=LONGVARCHAR},
ui_result = #{record.uiResult,jdbcType=LONGVARCHAR}, ui_result = #{record.uiResult,jdbcType=LONGVARCHAR},
api_base_count = #{record.apiBaseCount,jdbcType=LONGVARCHAR}, api_base_count = #{record.apiBaseCount,jdbcType=LONGVARCHAR},
ui_all_cases = #{record.uiAllCases,jdbcType=LONGVARCHAR} ui_all_cases = #{record.uiAllCases,jdbcType=LONGVARCHAR},
ui_failure_cases = #{record.uiFailureCases,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -656,6 +667,9 @@
<if test="uiAllCases != null"> <if test="uiAllCases != null">
ui_all_cases = #{uiAllCases,jdbcType=LONGVARCHAR}, ui_all_cases = #{uiAllCases,jdbcType=LONGVARCHAR},
</if> </if>
<if test="uiFailureCases != null">
ui_failure_cases = #{uiFailureCases,jdbcType=LONGVARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -692,7 +706,8 @@
plan_ui_scenario_report_struct = #{planUiScenarioReportStruct,jdbcType=LONGVARCHAR}, plan_ui_scenario_report_struct = #{planUiScenarioReportStruct,jdbcType=LONGVARCHAR},
ui_result = #{uiResult,jdbcType=LONGVARCHAR}, ui_result = #{uiResult,jdbcType=LONGVARCHAR},
api_base_count = #{apiBaseCount,jdbcType=LONGVARCHAR}, api_base_count = #{apiBaseCount,jdbcType=LONGVARCHAR},
ui_all_cases = #{uiAllCases,jdbcType=LONGVARCHAR} ui_all_cases = #{uiAllCases,jdbcType=LONGVARCHAR},
ui_failure_cases = #{uiFailureCases,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanReportContent"> <update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanReportContent">

View File

@ -59,4 +59,5 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
List<TestPlanFailureScenarioDTO> unExecuteScenarios; List<TestPlanFailureScenarioDTO> unExecuteScenarios;
List<TestPlanUiScenarioDTO> uiAllCases; List<TestPlanUiScenarioDTO> uiAllCases;
List<TestPlanUiScenarioDTO> uiFailureCases;
} }

View File

@ -979,6 +979,9 @@ public class TestPlanReportService {
if (StringUtils.isNotBlank(testPlanReportContent.getUiAllCases())) { if (StringUtils.isNotBlank(testPlanReportContent.getUiAllCases())) {
testPlanReportDTO.setUiAllCases(JSONObject.parseArray(testPlanReportContent.getUiAllCases(), TestPlanUiScenarioDTO.class)); testPlanReportDTO.setUiAllCases(JSONObject.parseArray(testPlanReportContent.getUiAllCases(), TestPlanUiScenarioDTO.class));
} }
if (StringUtils.isNotBlank(testPlanReportContent.getUiFailureCases())) {
testPlanReportDTO.setUiFailureCases(JSONObject.parseArray(testPlanReportContent.getUiFailureCases(), TestPlanUiScenarioDTO.class));
}
testPlanReportDTO.setId(reportId); testPlanReportDTO.setId(reportId);
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId()); TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId());
testPlanReportDTO.setName(testPlanReport.getName()); testPlanReportDTO.setName(testPlanReport.getName());

View File

@ -1422,6 +1422,17 @@ public class TestPlanService {
if (saveResponse) { if (saveResponse) {
buildUiScenarioResponse(allCases); buildUiScenarioResponse(allCases);
} }
if (checkReportConfig(config, "ui", "failure")) {
List<TestPlanUiScenarioDTO> failureCases = null;
if (!CollectionUtils.isEmpty(allCases)) {
failureCases = allCases.stream()
.filter(i -> StringUtils.isNotBlank(i.getStatus())
&& StringUtils.equalsAnyIgnoreCase(i.getStatus(), "Error"))
.collect(Collectors.toList());
}
report.setUiFailureCases(failureCases);
}
} }
} }
} }
@ -1886,6 +1897,7 @@ public class TestPlanService {
buildScenarioResponse(report.getScenarioAllCases()); buildScenarioResponse(report.getScenarioAllCases());
buildScenarioResponse(report.getScenarioFailureCases()); buildScenarioResponse(report.getScenarioFailureCases());
buildLoadResponse(report.getLoadAllCases()); buildLoadResponse(report.getLoadAllCases());
buildUiScenarioResponse(report.getUiAllCases());
report.setLang(lang); report.setLang(lang);
render(report, response); render(report, response);
} }