feat(测试计划报告): 测试计划报告增加误报数据配置

测试计划报告增加误报数据配置
This commit is contained in:
song-tianyang 2022-01-17 16:44:27 +08:00 committed by song-tianyang
parent 0919809099
commit a0cdee29c1
28 changed files with 363 additions and 190 deletions

View File

@ -204,8 +204,16 @@ public class ApiDefinitionExecResultService {
for (RequestResult item : requestResults) { for (RequestResult item : requestResults) {
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) { if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
this.save(item, dto.getReportId(), dto.getConsole(), countExpectProcessResultCount, dto.getRunMode(), dto.getTestId(), isFirst); ApiDefinitionExecResult reportResult = this.save(item, dto.getReportId(), dto.getConsole(), countExpectProcessResultCount, dto.getRunMode(), dto.getTestId(), isFirst);
String status = item.isSuccess() ? "success" : "error"; String status = item.isSuccess() ? "success" : "error";
if(reportResult != null){
status = reportResult.getStatus();
}
//对响应内容进行进一步解析如果有附加信息比如误报库信息则根据附加信息内的数据进行其他判读
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item);
if(MapUtils.isNotEmpty(expandDTO.getAttachInfoMap())){
status = expandDTO.getStatus();
}
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) { if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
TestPlanApiCase apiCase = testPlanApiCaseService.getById(dto.getTestId()); TestPlanApiCase apiCase = testPlanApiCaseService.getById(dto.getTestId());
if (apiCase != null) { if (apiCase != null) {

View File

@ -234,12 +234,18 @@ public class ApiScenarioReportService {
public ApiScenarioReport updatePlanCase(List<ApiScenarioReportResult> requestResults, ResultDTO dto) { public ApiScenarioReport updatePlanCase(List<ApiScenarioReportResult> requestResults, ResultDTO dto) {
long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count(); long errorSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Error.name())).count();
String status = getStatus(requestResults, dto);
ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode());
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(dto.getTestId()); TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(dto.getTestId());
if (testPlanApiScenario != null) { if (testPlanApiScenario != null) {
if (errorSize > 0) { if(report != null){
testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name()); testPlanApiScenario.setLastResult(report.getStatus());
} else { }else {
testPlanApiScenario.setLastResult(ScenarioStatus.Success.name()); if (errorSize > 0) {
testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name());
} else {
testPlanApiScenario.setLastResult(ScenarioStatus.Success.name());
}
} }
long successSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Success.name())).count(); long successSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Success.name())).count();
@ -263,8 +269,7 @@ public class ApiScenarioReportService {
apiScenarioMapper.updateByPrimaryKey(scenario); apiScenarioMapper.updateByPrimaryKey(scenario);
} }
} }
String status = getStatus(requestResults, dto);
ApiScenarioReport report = editReport(dto.getReportType(), dto.getReportId(), status, dto.getRunMode());
return report; return report;
} }
@ -284,11 +289,7 @@ public class ApiScenarioReportService {
report.setScenarioId(testPlanApiScenario.getApiScenarioId()); report.setScenarioId(testPlanApiScenario.getApiScenarioId());
report.setEndTime(System.currentTimeMillis()); report.setEndTime(System.currentTimeMillis());
apiScenarioReportMapper.updateByPrimaryKeySelective(report); apiScenarioReportMapper.updateByPrimaryKeySelective(report);
if (errorSize > 0) { testPlanApiScenario.setLastResult(report.getStatus());
testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name());
} else {
testPlanApiScenario.setLastResult(ScenarioStatus.Success.name());
}
long successSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Success.name())).count(); long successSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Success.name())).count();
String passRate = new DecimalFormat("0%").format((float) successSize / requestResults.size()); String passRate = new DecimalFormat("0%").format((float) successSize / requestResults.size());
testPlanApiScenario.setPassRate(passRate); testPlanApiScenario.setPassRate(passRate);

View File

@ -146,7 +146,6 @@ public class ApiScenarioReportStructureService {
} else if (step.getValue().getError() > 0) { } else if (step.getValue().getError() > 0) {
isError.set(isError.longValue() + 1); isError.set(isError.longValue() + 1);
} }
break;
} else if (CollectionUtils.isNotEmpty(step.getChildren())) { } else if (CollectionUtils.isNotEmpty(step.getChildren())) {
scenarioCalculate(step.getChildren(), isError, isErrorReport); scenarioCalculate(step.getChildren(), isError, isErrorReport);
} }

View File

@ -43,5 +43,9 @@ public class TestPlanReportContentWithBLOBs extends TestPlanReportContent implem
private String planLoadCaseReportStruct; private String planLoadCaseReportStruct;
private String errorReportCases;
private String errorReportScenarios;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -29,6 +29,8 @@
<result column="plan_scenario_report_struct" jdbcType="LONGVARCHAR" property="planScenarioReportStruct" /> <result column="plan_scenario_report_struct" jdbcType="LONGVARCHAR" property="planScenarioReportStruct" />
<result column="plan_api_case_report_struct" jdbcType="LONGVARCHAR" property="planApiCaseReportStruct" /> <result column="plan_api_case_report_struct" jdbcType="LONGVARCHAR" property="planApiCaseReportStruct" />
<result column="plan_load_case_report_struct" jdbcType="LONGVARCHAR" property="planLoadCaseReportStruct" /> <result column="plan_load_case_report_struct" jdbcType="LONGVARCHAR" property="planLoadCaseReportStruct" />
<result column="error_report_cases" jdbcType="LONGVARCHAR" property="errorReportCases" />
<result column="error_report_scenarios" jdbcType="LONGVARCHAR" property="errorReportScenarios" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -96,7 +98,7 @@
config, summary, function_result, api_result, load_result, function_all_cases, function_failure_cases, config, summary, function_result, api_result, load_result, function_all_cases, function_failure_cases,
issue_list, api_all_cases, api_failure_cases, scenario_all_cases, scenario_failure_cases, issue_list, api_all_cases, api_failure_cases, scenario_all_cases, scenario_failure_cases,
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 plan_load_case_report_struct, error_report_cases, error_report_scenarios
</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
@ -156,7 +158,8 @@
scenario_all_cases, scenario_failure_cases, scenario_all_cases, scenario_failure_cases,
load_all_Cases, load_failure_cases, load_all_Cases, load_failure_cases,
plan_scenario_report_struct, plan_api_case_report_struct, plan_scenario_report_struct, plan_api_case_report_struct,
plan_load_case_report_struct) plan_load_case_report_struct, error_report_cases,
error_report_scenarios)
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},
@ -166,7 +169,8 @@
#{scenarioAllCases,jdbcType=LONGVARCHAR}, #{scenarioFailureCases,jdbcType=LONGVARCHAR}, #{scenarioAllCases,jdbcType=LONGVARCHAR}, #{scenarioFailureCases,jdbcType=LONGVARCHAR},
#{loadAllCases,jdbcType=LONGVARCHAR}, #{loadFailureCases,jdbcType=LONGVARCHAR}, #{loadAllCases,jdbcType=LONGVARCHAR}, #{loadFailureCases,jdbcType=LONGVARCHAR},
#{planScenarioReportStruct,jdbcType=LONGVARCHAR}, #{planApiCaseReportStruct,jdbcType=LONGVARCHAR}, #{planScenarioReportStruct,jdbcType=LONGVARCHAR}, #{planApiCaseReportStruct,jdbcType=LONGVARCHAR},
#{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}) #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, #{errorReportCases,jdbcType=LONGVARCHAR},
#{errorReportScenarios,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
@ -246,6 +250,12 @@
<if test="planLoadCaseReportStruct != null"> <if test="planLoadCaseReportStruct != null">
plan_load_case_report_struct, plan_load_case_report_struct,
</if> </if>
<if test="errorReportCases != null">
error_report_cases,
</if>
<if test="errorReportScenarios != null">
error_report_scenarios,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -323,6 +333,12 @@
<if test="planLoadCaseReportStruct != null"> <if test="planLoadCaseReportStruct != null">
#{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR},
</if> </if>
<if test="errorReportCases != null">
#{errorReportCases,jdbcType=LONGVARCHAR},
</if>
<if test="errorReportScenarios != null">
#{errorReportScenarios,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">
@ -409,6 +425,12 @@
<if test="record.planLoadCaseReportStruct != null"> <if test="record.planLoadCaseReportStruct != null">
plan_load_case_report_struct = #{record.planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, plan_load_case_report_struct = #{record.planLoadCaseReportStruct,jdbcType=LONGVARCHAR},
</if> </if>
<if test="record.errorReportCases != null">
error_report_cases = #{record.errorReportCases,jdbcType=LONGVARCHAR},
</if>
<if test="record.errorReportScenarios != null">
error_report_scenarios = #{record.errorReportScenarios,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" />
@ -440,7 +462,9 @@
load_failure_cases = #{record.loadFailureCases,jdbcType=LONGVARCHAR}, load_failure_cases = #{record.loadFailureCases,jdbcType=LONGVARCHAR},
plan_scenario_report_struct = #{record.planScenarioReportStruct,jdbcType=LONGVARCHAR}, plan_scenario_report_struct = #{record.planScenarioReportStruct,jdbcType=LONGVARCHAR},
plan_api_case_report_struct = #{record.planApiCaseReportStruct,jdbcType=LONGVARCHAR}, plan_api_case_report_struct = #{record.planApiCaseReportStruct,jdbcType=LONGVARCHAR},
plan_load_case_report_struct = #{record.planLoadCaseReportStruct,jdbcType=LONGVARCHAR} plan_load_case_report_struct = #{record.planLoadCaseReportStruct,jdbcType=LONGVARCHAR},
error_report_cases = #{record.errorReportCases,jdbcType=LONGVARCHAR},
error_report_scenarios = #{record.errorReportScenarios,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>
@ -534,6 +558,12 @@
<if test="planLoadCaseReportStruct != null"> <if test="planLoadCaseReportStruct != null">
plan_load_case_report_struct = #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, plan_load_case_report_struct = #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR},
</if> </if>
<if test="errorReportCases != null">
error_report_cases = #{errorReportCases,jdbcType=LONGVARCHAR},
</if>
<if test="errorReportScenarios != null">
error_report_scenarios = #{errorReportScenarios,jdbcType=LONGVARCHAR},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -562,7 +592,9 @@
load_failure_cases = #{loadFailureCases,jdbcType=LONGVARCHAR}, load_failure_cases = #{loadFailureCases,jdbcType=LONGVARCHAR},
plan_scenario_report_struct = #{planScenarioReportStruct,jdbcType=LONGVARCHAR}, plan_scenario_report_struct = #{planScenarioReportStruct,jdbcType=LONGVARCHAR},
plan_api_case_report_struct = #{planApiCaseReportStruct,jdbcType=LONGVARCHAR}, plan_api_case_report_struct = #{planApiCaseReportStruct,jdbcType=LONGVARCHAR},
plan_load_case_report_struct = #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR} plan_load_case_report_struct = #{planLoadCaseReportStruct,jdbcType=LONGVARCHAR},
error_report_cases = #{errorReportCases,jdbcType=LONGVARCHAR},
error_report_scenarios = #{errorReportScenarios,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

@ -321,7 +321,7 @@
on t.api_case_id = c.id on t.api_case_id = c.id
and t.test_plan_id = #{planId} and t.test_plan_id = #{planId}
<if test="status != null"> <if test="status != null">
and t.status = 'error' and t.status = #{status}
</if> </if>
and (c.status != 'Trash' or c.status is null) and (c.status != 'Trash' or c.status is null)
where t.test_plan_id = #{planId}; where t.test_plan_id = #{planId};

View File

@ -214,7 +214,7 @@
on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null) on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
and t.test_plan_id = #{planId} and t.test_plan_id = #{planId}
<if test="status != null"> <if test="status != null">
and t.last_result = 'Fail' and t.last_result = #{status}
</if> </if>
where t.test_plan_id = #{planId} where t.test_plan_id = #{planId}
</select> </select>

View File

@ -1,5 +1,6 @@
package io.metersphere.commons.utils; package io.metersphere.commons.utils;
import io.metersphere.commons.constants.ExecuteResult;
import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.track.dto.PlanReportCaseDTO; import io.metersphere.track.dto.PlanReportCaseDTO;
import io.metersphere.track.dto.TestCaseReportStatusResultDTO; import io.metersphere.track.dto.TestCaseReportStatusResultDTO;
@ -51,6 +52,7 @@ public class TestPlanUtils {
addToReportStatusResultList(resultMap, statusResult, "Success"); addToReportStatusResultList(resultMap, statusResult, "Success");
addToReportStatusResultList(resultMap, statusResult, "SUCCESS"); addToReportStatusResultList(resultMap, statusResult, "SUCCESS");
addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name()); addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name());
addToReportStatusResultList(resultMap, statusResult, ExecuteResult.errorReportResult.name());
} }
/** /**

View File

@ -112,7 +112,11 @@ public class ShareController {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId, planId);
return testPlanApiCaseService.getFailureCases(planId); return testPlanApiCaseService.getFailureCases(planId);
} }
@GetMapping("/test/plan/api/case/list/errorReport/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getErrorReportApiCaseList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return testPlanApiCaseService.getErrorReportCases(planId);
}
@GetMapping("/test/plan/api/case/list/all/{shareId}/{planId}") @GetMapping("/test/plan/api/case/list/all/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getApiAllList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureApiDTO> getApiAllList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId, planId);
@ -131,6 +135,12 @@ public class ShareController {
return testPlanScenarioCaseService.getAllCases(planId); return testPlanScenarioCaseService.getAllCases(planId);
} }
@GetMapping("/test/plan/scenario/case/list/errorReport/{shareId}/{planId}")
public List<TestPlanFailureScenarioDTO> getScenarioErrorReportList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return testPlanScenarioCaseService.getErrorReportCases(planId);
}
@GetMapping("/api/definition/report/getReport/{shareId}/{testId}") @GetMapping("/api/definition/report/getReport/{shareId}/{testId}")
public APIReportResult getApiReport(@PathVariable String shareId, @PathVariable String testId) { public APIReportResult getApiReport(@PathVariable String shareId, @PathVariable String testId) {
// shareInfoService.apiReportValidate(shareId, testId); // shareInfoService.apiReportValidate(shareId, testId);

View File

@ -40,6 +40,11 @@ public class TestPlanApiCaseController {
return testPlanApiCaseService.getFailureCases(planId); return testPlanApiCaseService.getFailureCases(planId);
} }
@GetMapping("/list/errorReport/{planId}")
public List<TestPlanFailureApiDTO> getErrorReportList(@PathVariable String planId) {
return testPlanApiCaseService.getErrorReportCases(planId);
}
@GetMapping("/list/all/{planId}") @GetMapping("/list/all/{planId}")
public List<TestPlanFailureApiDTO> getAllList(@PathVariable String planId) { public List<TestPlanFailureApiDTO> getAllList(@PathVariable String planId) {
return testPlanApiCaseService.getAllCases(planId); return testPlanApiCaseService.getAllCases(planId);

View File

@ -40,6 +40,11 @@ public class TestPlanScenarioCaseController {
return testPlanScenarioCaseService.getFailureCases(planId); return testPlanScenarioCaseService.getFailureCases(planId);
} }
@GetMapping("/list/errorReport/{planId}")
public List<TestPlanFailureScenarioDTO> getErrorReportList(@PathVariable String planId) {
return testPlanScenarioCaseService.getErrorReportCases(planId);
}
@GetMapping("/list/all/{planId}") @GetMapping("/list/all/{planId}")
public List<TestPlanFailureScenarioDTO> getAllList(@PathVariable String planId) { public List<TestPlanFailureScenarioDTO> getAllList(@PathVariable String planId) {
return testPlanScenarioCaseService.getAllCases(planId); return testPlanScenarioCaseService.getAllCases(planId);

View File

@ -12,6 +12,7 @@ public class TestPlanScenarioStepCountDTO {
private int scenarioStepTotal; private int scenarioStepTotal;
private int scenarioStepSuccess; private int scenarioStepSuccess;
private int scenarioStepError; private int scenarioStepError;
private int scenarioStepErrorReport;
private List<String> underwayIds = new ArrayList<>(); private List<String> underwayIds = new ArrayList<>();
private int scenarioStepUnderway; private int scenarioStepUnderway;
} }

View File

@ -33,4 +33,6 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
List<TestPlanFailureScenarioDTO> scenarioAllCases; List<TestPlanFailureScenarioDTO> scenarioAllCases;
List<TestPlanLoadCaseDTO> loadAllCases; List<TestPlanLoadCaseDTO> loadAllCases;
List<TestPlanLoadCaseDTO> loadFailureCases; List<TestPlanLoadCaseDTO> loadFailureCases;
List<TestPlanFailureApiDTO> errorReportCases;
List<TestPlanFailureScenarioDTO> errorReportScenarios;
} }

View File

@ -17,6 +17,7 @@ import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.TestPlanApiCaseMapper; import io.metersphere.base.mapper.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.constants.ExecuteResult;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.dto.MsExecResponseDTO; import io.metersphere.dto.MsExecResponseDTO;
@ -435,4 +436,9 @@ public class TestPlanApiCaseService {
} }
return buildCases(apiTestCases); return buildCases(apiTestCases);
} }
public List<TestPlanFailureApiDTO> getErrorReportCases(String planId) {
List<TestPlanFailureApiDTO> apiTestCases = extTestPlanApiCaseMapper.getFailureList(planId, ExecuteResult.errorReportResult.name());
return buildCases(apiTestCases);
}
} }

View File

@ -460,6 +460,12 @@ public class TestPlanReportService {
if (reportDTO.getLoadFailureCases() != null) { if (reportDTO.getLoadFailureCases() != null) {
testPlanReportContentWithBLOBs.setLoadFailureCases(JSONObject.toJSONString(reportDTO.getLoadFailureCases())); testPlanReportContentWithBLOBs.setLoadFailureCases(JSONObject.toJSONString(reportDTO.getLoadFailureCases()));
} }
if (reportDTO.getErrorReportCases() != null) {
testPlanReportContentWithBLOBs.setErrorReportCases(JSONObject.toJSONString(reportDTO.getErrorReportCases()));
}
if (reportDTO.getErrorReportScenarios() != null) {
testPlanReportContentWithBLOBs.setErrorReportScenarios(JSONObject.toJSONString(reportDTO.getErrorReportScenarios()));
}
return testPlanReportContentWithBLOBs; return testPlanReportContentWithBLOBs;
} }
@ -732,6 +738,12 @@ public class TestPlanReportService {
if (StringUtils.isNotBlank(testPlanReportContent.getLoadFailureCases())) { if (StringUtils.isNotBlank(testPlanReportContent.getLoadFailureCases())) {
testPlanReportDTO.setLoadFailureCases(JSONObject.parseArray(testPlanReportContent.getLoadFailureCases(), TestPlanLoadCaseDTO.class)); testPlanReportDTO.setLoadFailureCases(JSONObject.parseArray(testPlanReportContent.getLoadFailureCases(), TestPlanLoadCaseDTO.class));
} }
if (StringUtils.isNotBlank(testPlanReportContent.getErrorReportCases())) {
testPlanReportDTO.setErrorReportCases(JSONObject.parseArray(testPlanReportContent.getErrorReportCases(), TestPlanFailureApiDTO.class));
}
if (StringUtils.isNotBlank(testPlanReportContent.getErrorReportScenarios())) {
testPlanReportDTO.setErrorReportScenarios(JSONObject.parseArray(testPlanReportContent.getErrorReportScenarios(), TestPlanFailureScenarioDTO.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

@ -15,6 +15,7 @@ import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ExecuteResult;
import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
@ -450,15 +451,13 @@ public class TestPlanScenarioCaseService {
for (PlanReportCaseDTO item : planReportCaseDTOS) { for (PlanReportCaseDTO item : planReportCaseDTOS) {
calculateScenarioResultDTO(item, stepCount); calculateScenarioResultDTO(item, stepCount);
} }
int underwayStepsCounts = getUnderwayStepsCounts(stepCount.getUnderwayIds()); int underwayStepsCounts = getUnderwayStepsCounts(stepCount.getUnderwayIds());
List<TestCaseReportStatusResultDTO> stepResult = new ArrayList<>(); List<TestCaseReportStatusResultDTO> stepResult = new ArrayList<>();
getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Failure.name(), stepCount.getScenarioStepError(), stepResult); getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Failure.name(), stepCount.getScenarioStepError(), stepResult);
getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Pass.name(), stepCount.getScenarioStepSuccess(), stepResult); getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Pass.name(), stepCount.getScenarioStepSuccess(), stepResult);
getScenarioCaseReportStatusResultDTO(ExecuteResult.errorReportResult.name(), stepCount.getScenarioStepErrorReport(), stepResult);
getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Underway.name(), getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Underway.name(),
stepCount.getScenarioStepTotal() - stepCount.getScenarioStepSuccess() - stepCount.getScenarioStepError() + underwayStepsCounts, stepResult); stepCount.getScenarioStepTotal() - stepCount.getScenarioStepSuccess() - stepCount.getScenarioStepError() -stepCount.getScenarioStepErrorReport() + underwayStepsCounts, stepResult);
apiResult.setApiScenarioData(statusResult); apiResult.setApiScenarioData(statusResult);
apiResult.setApiScenarioStepData(stepResult); apiResult.setApiScenarioStepData(stepResult);
} }
@ -488,6 +487,7 @@ public class TestPlanScenarioCaseService {
stepCount.setScenarioStepTotal(stepCount.getScenarioStepTotal() + jsonObject.getIntValue("scenarioStepTotal")); stepCount.setScenarioStepTotal(stepCount.getScenarioStepTotal() + jsonObject.getIntValue("scenarioStepTotal"));
stepCount.setScenarioStepSuccess(stepCount.getScenarioStepSuccess() + jsonObject.getIntValue("scenarioStepSuccess")); stepCount.setScenarioStepSuccess(stepCount.getScenarioStepSuccess() + jsonObject.getIntValue("scenarioStepSuccess"));
stepCount.setScenarioStepError(stepCount.getScenarioStepError() + jsonObject.getIntValue("scenarioStepError")); stepCount.setScenarioStepError(stepCount.getScenarioStepError() + jsonObject.getIntValue("scenarioStepError"));
stepCount.setScenarioStepErrorReport(stepCount.getScenarioStepErrorReport() + jsonObject.getIntValue("scenarioStepErrorReport"));
} }
} }
} else { } else {
@ -583,4 +583,9 @@ public class TestPlanScenarioCaseService {
testPlanApiScenarioMapper::updateByPrimaryKeySelective); testPlanApiScenarioMapper::updateByPrimaryKeySelective);
} }
public List<TestPlanFailureScenarioDTO> getErrorReportCases(String planId) {
List<TestPlanFailureScenarioDTO> apiTestCases =
extTestPlanScenarioCaseMapper.getFailureList(planId, ExecuteResult.errorReportResult.name());
return buildCases(apiTestCases);
}
} }

View File

@ -166,8 +166,6 @@ public class TestPlanService {
@Resource @Resource
private ApiDefinitionService apiDefinitionService; private ApiDefinitionService apiDefinitionService;
@Resource @Resource
private IssueTemplateService issueTemplateService;
@Resource
private PerformanceReportService performanceReportService; private PerformanceReportService performanceReportService;
@Resource @Resource
private MetricQueryService metricQueryService; private MetricQueryService metricQueryService;
@ -1461,37 +1459,9 @@ public class TestPlanService {
} }
report.setScenarioAllCases(scenarioAllCases); report.setScenarioAllCases(scenarioAllCases);
} }
if (checkReportConfig(config, "api", "failure")) { //筛选符合配置需要的执行结果的用例和场景
// 接口 this.screenApiCaseByStatusAndReportConfig(report, apiAllCases, config);
List<TestPlanFailureApiDTO> apiFailureCases = null; this.screenScenariosByStatusAndReportConfig(report, scenarioAllCases, config);
if (!CollectionUtils.isEmpty(apiAllCases)) {
apiFailureCases = apiAllCases.stream()
.filter(i -> StringUtils.isNotBlank(i.getExecResult())
&& i.getExecResult().equals("error"))
.collect(Collectors.toList());
} else {
apiFailureCases = testPlanApiCaseService.getFailureCases(planId);
}
if (saveResponse) {
buildApiResponse(apiFailureCases);
}
report.setApiFailureCases(apiFailureCases);
// 场景
List<TestPlanFailureScenarioDTO> scenarioFailureCases = null;
if (!CollectionUtils.isEmpty(scenarioAllCases)) {
scenarioFailureCases = scenarioAllCases.stream()
.filter(i -> StringUtils.isNotBlank(i.getLastResult())
&& i.getLastResult().equals("Fail"))
.collect(Collectors.toList());
} else {
scenarioFailureCases = testPlanScenarioCaseService.getFailureCases(planId);
}
if (saveResponse) {
buildScenarioResponse(scenarioFailureCases);
}
report.setScenarioFailureCases(scenarioFailureCases);
}
} }
} }
@ -1651,26 +1621,51 @@ public class TestPlanService {
report.setScenarioAllCases(scenarioAllCases); report.setScenarioAllCases(scenarioAllCases);
} }
} }
if (checkReportConfig(config, "api", "failure")) {
// 接口
List<TestPlanFailureApiDTO> apiFailureCases = null;
if (!CollectionUtils.isEmpty(apiAllCases)) {
apiFailureCases = apiAllCases.stream()
.filter(i -> StringUtils.isNotBlank(i.getExecResult())
&& i.getExecResult().equals("error"))
.collect(Collectors.toList());
}
report.setApiFailureCases(apiFailureCases);
// 场景 //筛选符合配置需要的执行结果的用例和场景
List<TestPlanFailureScenarioDTO> scenarioFailureCases = null; this.screenApiCaseByStatusAndReportConfig(report, apiAllCases, config);
if (!CollectionUtils.isEmpty(scenarioAllCases)) { this.screenScenariosByStatusAndReportConfig(report, scenarioAllCases, config);
scenarioFailureCases = scenarioAllCases.stream() }
.filter(i -> StringUtils.isNotBlank(i.getLastResult()) }
&& i.getLastResult().equals("Fail"))
.collect(Collectors.toList()); private void screenScenariosByStatusAndReportConfig(TestPlanSimpleReportDTO report, List<TestPlanFailureScenarioDTO> scenarios, JSONObject reportConfig) {
if (!CollectionUtils.isEmpty(scenarios)) {
List<TestPlanFailureScenarioDTO> failureScenarios = new ArrayList<>();
List<TestPlanFailureScenarioDTO> errorReportScenarios = new ArrayList<>();
for (TestPlanFailureScenarioDTO scenario : scenarios) {
if (StringUtils.equalsIgnoreCase(scenario.getLastResult(), "Fail")) {
failureScenarios.add(scenario);
} else if (StringUtils.equalsIgnoreCase(scenario.getLastResult(), ExecuteResult.errorReportResult.name())) {
errorReportScenarios.add(scenario);
} }
report.setScenarioFailureCases(scenarioFailureCases); }
if (checkReportConfig(reportConfig, "api", "failure")) {
report.setScenarioFailureCases(failureScenarios);
}
if (checkReportConfig(reportConfig, "api", "errorReport")) {
report.setErrorReportScenarios(errorReportScenarios);
}
}
}
private void screenApiCaseByStatusAndReportConfig(TestPlanSimpleReportDTO report, List<TestPlanFailureApiDTO> apiAllCases, JSONObject reportConfig) {
if (!CollectionUtils.isEmpty(apiAllCases)) {
List<TestPlanFailureApiDTO> apiFailureCases = new ArrayList<>();
List<TestPlanFailureApiDTO> apiErrorReportCases = new ArrayList<>();
for (TestPlanFailureApiDTO apiDTO : apiAllCases) {
if (StringUtils.equalsIgnoreCase(apiDTO.getExecResult(), "error")) {
apiFailureCases.add(apiDTO);
} else if (StringUtils.equalsIgnoreCase(apiDTO.getExecResult(), ExecuteResult.errorReportResult.name())) {
apiErrorReportCases.add(apiDTO);
}
}
if (checkReportConfig(reportConfig, "api", "failure")) {
report.setApiFailureCases(apiFailureCases);
}
if (checkReportConfig(reportConfig, "api", "errorReport")) {
report.setErrorReportCases(apiErrorReportCases);
} }
} }
} }

View File

@ -190,3 +190,6 @@ SET ref_id = id;
UPDATE test_case UPDATE test_case
INNER JOIN project_version ON project_version.project_id = test_case.project_id INNER JOIN project_version ON project_version.project_id = test_case.project_id
SET version_id = project_version.id; SET version_id = project_version.id;
ALTER TABLE `test_plan_report_content` ADD COLUMN `error_report_cases` LONGTEXT COMMENT '误报状态接口用例';
ALTER TABLE `test_plan_report_content` ADD COLUMN `error_report_scenarios` LONGTEXT COMMENT '误报状态场景用例';

View File

@ -118,6 +118,7 @@ export const REQUIRED = [
export const RESULT_MAP = new Map([ export const RESULT_MAP = new Map([
['success', '通过'], ['success', '通过'],
['error', '未通过'], ['error', '未通过'],
['default', '未执行'] ['default', '未执行'],
['errorReportResult', '误报']
]); ]);

View File

@ -9,6 +9,7 @@
<ms-tag v-else-if="value == 'Failure'" type="danger" :content="$t('test_track.plan_view.failure')"/> <ms-tag v-else-if="value == 'Failure'" type="danger" :content="$t('test_track.plan_view.failure')"/>
<ms-tag v-else-if="value == 'Blocking'" type="warning" :content="$t('test_track.plan_view.blocking')"/> <ms-tag v-else-if="value == 'Blocking'" type="warning" :content="$t('test_track.plan_view.blocking')"/>
<ms-tag v-else-if="value == 'Skip'" type="info" :content="$t('test_track.plan_view.skip')"/> <ms-tag v-else-if="value == 'Skip'" type="info" :content="$t('test_track.plan_view.skip')"/>
<ms-tag v-else-if="value == 'ErrorReportResult'" type="warning" style="background-color: #F6972A; border-color: #F6972A" :content="$t('error_report_library.option.name')"/>
<ms-tag v-else type="info" :content="value"/> <ms-tag v-else type="info" :content="value"/>
</span> </span>
</template> </template>

View File

@ -142,6 +142,9 @@
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'Fail'"> <el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'Fail'">
{{ $t('api_test.automation.fail') }} {{ $t('api_test.automation.fail') }}
</el-link> </el-link>
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'errorReportResult'">
{{ $t('error_report_library.option.name') }}
</el-link>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column :field="item" <ms-table-column :field="item"

View File

@ -8,13 +8,22 @@
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('test_track.report.fail_case')" :count="failureSize"/> <tab-pane-count :title="$t('test_track.report.fail_case')" :count="failureSize"/>
</template> </template>
<api-cases :is-db="isDb" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate" :plan-id="planId" @setSize="setFailureSize"/> <api-cases :is-db="isDb" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate"
:plan-id="planId" @setSize="setFailureSize"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane style="min-height: 500px" name="third" v-if="allEnable"> <el-tab-pane style="min-height: 500px" name="third" v-if="errorReportEnable">
<template v-slot:label>
<tab-pane-count :title="$t('error_report_library.option.name')" :count="errorReportSize"/>
</template>
<api-cases :is-db="isDb" :is-error-report="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setErrorReportSize"/>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="fourth" v-if="allEnable">
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('test_track.report.all_case')" :count="allSize"/> <tab-pane-count :title="$t('test_track.report.all_case')" :count="allSize"/>
</template> </template>
<api-cases :is-db="isDb" :is-all="true" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate" :plan-id="planId" @setSize="setAllSize"/> <api-cases :is-db="isDb" :is-all="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setAllSize"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</test-plan-report-container> </test-plan-report-container>
@ -27,6 +36,7 @@ import TestPlanReportContainer
from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContainer"; from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContainer";
import ApiCases from "@/business/components/track/plan/view/comonents/report/detail/component/ApiCases"; import ApiCases from "@/business/components/track/plan/view/comonents/report/detail/component/ApiCases";
import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount"; import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount";
export default { export default {
name: "TestPlanApiReport", name: "TestPlanApiReport",
components: {TabPaneCount, ApiCases, TestPlanReportContainer, ApiResult, MsFormDivider}, components: {TabPaneCount, ApiCases, TestPlanReportContainer, ApiResult, MsFormDivider},
@ -34,6 +44,7 @@ export default {
return { return {
activeName: 'first', activeName: 'first',
failureSize: 0, failureSize: 0,
errorReportSize: 0,
allSize: 0, allSize: 0,
}; };
}, },
@ -49,6 +60,10 @@ export default {
let disable = this.report.config && this.report.config.api.children.failure.enable === false; let disable = this.report.config && this.report.config.api.children.failure.enable === false;
return !disable; return !disable;
}, },
errorReportEnable() {
let disable = this.report.config && this.report.config.api.children.errorReport && this.report.config.api.children.errorReport.enable === false;
return !disable;
},
allEnable() { allEnable() {
let disable = this.report.config && this.report.config.api.children.all.enable === false; let disable = this.report.config && this.report.config.api.children.all.enable === false;
return !disable; return !disable;
@ -61,6 +76,9 @@ export default {
failureEnable() { failureEnable() {
this.initActiveName(); this.initActiveName();
}, },
errorReportEnable() {
this.initActiveName();
},
allEnable() { allEnable() {
this.initActiveName(); this.initActiveName();
}, },
@ -74,13 +92,18 @@ export default {
this.activeName = 'first'; this.activeName = 'first';
} else if (this.failureEnable) { } else if (this.failureEnable) {
this.activeName = 'second'; this.activeName = 'second';
} else if (this.allEnable) { } else if (this.errorReportEnable) {
this.activeName = 'third'; this.activeName = 'third';
} else if (this.allEnable) {
this.activeName = 'fourth';
} }
}, },
setFailureSize(size) { setFailureSize(size) {
this.failureSize = size; this.failureSize = size;
}, },
setErrorReportSize(size) {
this.errorReportSize = size;
},
setAllSize(size) { setAllSize(size) {
this.allSize = size; this.allSize = size;
}, },

View File

@ -205,6 +205,10 @@ export default {
enable: true, enable: true,
name: this.$t('test_track.report.fail_case'), name: this.$t('test_track.report.fail_case'),
}, },
errorReport: {
enable: true,
name: this.$t('error_report_library.option.name'),
},
all: { all: {
enable: true, enable: true,
name: this.$t('test_track.report.all_case'), name: this.$t('test_track.report.all_case'),

View File

@ -1,62 +1,64 @@
<template> <template>
<el-container> <el-container>
<ms-aside-container width="500px" :default-hidden-bottom-top="200" :enable-auto-height="true"> <ms-aside-container width="500px" :default-hidden-bottom-top="200" :enable-auto-height="true">
<el-card> <el-card>
<el-scrollbar> <el-scrollbar>
<ms-table v-loading="result.loading" <ms-table v-loading="result.loading"
:show-select-all="false" :show-select-all="false"
:screen-height="null" :screen-height="null"
:enable-selection="false" :enable-selection="false"
:highlight-current-row="true" :highlight-current-row="true"
@refresh="getScenarioApiCase" @refresh="getScenarioApiCase"
@handleRowClick="rowClick" @handleRowClick="rowClick"
:data="apiCases"> :data="apiCases">
<ms-table-column <ms-table-column
:width="80" :width="80"
:label="$t('commons.id')" :label="$t('commons.id')"
prop="num"> prop="num">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:label="$t('commons.name')" :label="$t('commons.name')"
prop="name"> prop="name">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:label="$t('commons.create_user')" :label="$t('commons.create_user')"
prop="creatorName"/> prop="creatorName"/>
<ms-table-column <ms-table-column
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')"
:width="80" :width="80"
prop="priority"> prop="priority">
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/> <priority-table-item :value="scope.row.priority" ref="priority"/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:width="80" :width="80"
:label="$t('test_track.plan_view.execute_result')" :label="$t('test_track.plan_view.execute_result')"
prop="lastResult"> prop="lastResult">
<template v-slot:default="scope"> <template v-slot:default="scope">
<status-table-item v-if="scope.row.execResult === 'success'" :value="'Pass'"/> <status-table-item v-if="scope.row.execResult === 'success'" :value="'Pass'"/>
<status-table-item v-else-if="scope.row.execResult === 'error'" :value="'Failure'"/> <status-table-item v-else-if="scope.row.execResult === 'error'" :value="'Failure'"/>
<status-table-item v-else-if="scope.row.execResult === 'STOP'" :value="'STOP'"/> <status-table-item v-else-if="scope.row.execResult === 'STOP'" :value="'STOP'"/>
<status-table-item v-else :value="'Prepare'"/> <status-table-item v-else-if="scope.row.execResult === 'errorReportResult'"
</template> :value="'ErrorReportResult'"/>
</ms-table-column> <status-table-item v-else :value="'Prepare'"/>
</ms-table> </template>
</el-scrollbar> </ms-table-column>
</el-card> </ms-table>
</ms-aside-container> </el-scrollbar>
<ms-main-container> </el-card>
<el-card v-if="showResponse"> </ms-aside-container>
<ms-request-result-tail :response="response" ref="debugResult"/> <ms-main-container>
</el-card> <el-card v-if="showResponse">
<div class="empty" v-else>{{ $t('test_track.plan.load_case.content_empty') }}</div> <ms-request-result-tail :response="response" ref="debugResult"/>
</ms-main-container> </el-card>
<div class="empty" v-else>{{ $t('test_track.plan.load_case.content_empty') }}</div>
</ms-main-container>
</el-container> </el-container>
</template> </template>
@ -66,9 +68,9 @@ import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTabl
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem"; import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem"; import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import { import {
getPlanApiAllCase, getPlanApiAllCase, getPlanApiErrorReportCase,
getPlanApiFailureCase, getPlanApiFailureCase,
getSharePlanApiAllCase, getSharePlanApiAllCase, getSharePlanApiErrorReportCase,
getSharePlanApiFailureCase getSharePlanApiFailureCase
} from "@/network/test-plan"; } from "@/network/test-plan";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
@ -77,13 +79,15 @@ import {getApiReport, getShareApiReport} from "@/network/api";
import MsRequestResultTail from "@/business/components/api/definition/components/response/RequestResultTail"; import MsRequestResultTail from "@/business/components/api/definition/components/response/RequestResultTail";
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
export default { export default {
name: "ApiCaseFailureResult", name: "ApiCaseFailureResult",
components: { components: {
MsMainContainer, MsMainContainer,
MsAsideContainer, MsAsideContainer,
MsRequestResultTail, MsRequestResultTail,
MsTableColumn, MsTable, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem}, MsTableColumn, MsTable, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem
},
props: { props: {
planId: String, planId: String,
isTemplate: Boolean, isTemplate: Boolean,
@ -91,6 +95,7 @@ export default {
isShare: Boolean, isShare: Boolean,
shareId: String, shareId: String,
isAll: Boolean, isAll: Boolean,
isErrorReport: Boolean,
isDb: Boolean isDb: Boolean
}, },
data() { data() {
@ -116,13 +121,19 @@ export default {
methods: { methods: {
getScenarioApiCase() { getScenarioApiCase() {
if (this.isTemplate || this.isDb) { if (this.isTemplate || this.isDb) {
if (this.isAll) { if(this.isErrorReport){
this.apiCases = this.report.errorReportCases ? this.report.errorReportCases : [];
}else if (this.isAll) {
this.apiCases = this.report.apiAllCases ? this.report.apiAllCases : []; this.apiCases = this.report.apiAllCases ? this.report.apiAllCases : [];
} else { } else {
this.apiCases = this.report.apiFailureCases ? this.report.apiFailureCases : []; this.apiCases = this.report.apiFailureCases ? this.report.apiFailureCases : [];
} }
} else if (this.isShare) { } else if (this.isShare) {
if (this.isAll) { if(this.isErrorReport){
this.result = getSharePlanApiErrorReportCase(this.shareId, this.planId, (data) => {
this.apiCases = data;
});
}else if (this.isAll) {
this.result = getSharePlanApiAllCase(this.shareId, this.planId, (data) => { this.result = getSharePlanApiAllCase(this.shareId, this.planId, (data) => {
this.apiCases = data; this.apiCases = data;
}); });
@ -132,7 +143,11 @@ export default {
}); });
} }
} else { } else {
if (this.isAll) { if(this.isErrorReport){
this.result = getPlanApiErrorReportCase(this.planId, (data) => {
this.apiCases = data;
});
}else if (this.isAll) {
this.result = getPlanApiAllCase(this.planId, (data) => { this.result = getPlanApiAllCase(this.planId, (data) => {
this.apiCases = data; this.apiCases = data;
}); });

View File

@ -5,15 +5,16 @@
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('commons.api_case')" :count="apiSize"/> <tab-pane-count :title="$t('commons.api_case')" :count="apiSize"/>
</template> </template>
<api-case-failure-result :is-db="isDb" :is-all="isAll" :share-id="shareId" :is-share="isShare" <api-case-failure-result :is-db="isDb" :is-all="isAll" :is-error-report="isErrorReport" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId" @setSize="setApiSize"/> :report="report" :is-template="isTemplate" :plan-id="planId" @setSize="setApiSize"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane> <el-tab-pane>
<template v-slot:label> <template v-slot:label>
<tab-pane-count :title="$t('commons.scenario_case')" :count="scenarioSize"/> <tab-pane-count :title="$t('commons.scenario_case')" :count="scenarioSize"/>
</template> </template>
<api-scenario-failure-result :is-db="isDb" :is-all="isAll" :share-id="shareId" :is-share="isShare" <api-scenario-failure-result :is-db="isDb" :is-all="isAll" :is-error-report="isErrorReport" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId" @setSize="setScenarioSize"/> :report="report" :is-template="isTemplate" :plan-id="planId"
@setSize="setScenarioSize"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
@ -29,12 +30,14 @@ import ApiScenarioFailureResult
import ApiCaseFailureResult import ApiCaseFailureResult
from "@/business/components/track/plan/view/comonents/report/detail/component/ApiCaseFailureResult"; from "@/business/components/track/plan/view/comonents/report/detail/component/ApiCaseFailureResult";
import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount"; import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount";
export default { export default {
name: "ApiCases", name: "ApiCases",
components: { components: {
TabPaneCount, TabPaneCount,
ApiCaseFailureResult, ApiCaseFailureResult,
ApiScenarioFailureResult, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem}, ApiScenarioFailureResult, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem
},
props: { props: {
planId: String, planId: String,
isTemplate: Boolean, isTemplate: Boolean,
@ -42,6 +45,7 @@ export default {
report: {}, report: {},
shareId: String, shareId: String,
isAll: Boolean, isAll: Boolean,
isErrorReport: Boolean,
isDb: Boolean isDb: Boolean
}, },
data() { data() {

View File

@ -33,6 +33,7 @@ export default {
["Failure", {name: this.$t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], ["Failure", {name: this.$t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}],
["Prepare", {name: this.$t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], ["Prepare", {name: this.$t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}],
["Underway", {name: this.$t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], ["Underway", {name: this.$t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}],
["errorReportResult", {name: this.$t('error_report_library.option.name'), itemStyle: {color: '#F6972A'}}],
]), ]),
caseCharData: [], caseCharData: [],
scenarioCharData: [], scenarioCharData: [],

View File

@ -1,64 +1,66 @@
<template> <template>
<el-container class="scenario-info"> <el-container class="scenario-info">
<ms-aside-container width="500px" :default-hidden-bottom-top="200" :enable-auto-height="true"> <ms-aside-container width="500px" :default-hidden-bottom-top="200" :enable-auto-height="true">
<el-card> <el-card>
<el-scrollbar> <el-scrollbar>
<ms-table v-loading="result.loading" <ms-table v-loading="result.loading"
:show-select-all="false" :show-select-all="false"
:screen-height="null" :screen-height="null"
:enable-selection="false" :enable-selection="false"
:highlight-current-row="true" :highlight-current-row="true"
@refresh="getScenarioApiCase" @refresh="getScenarioApiCase"
@handleRowClick="rowClick" @handleRowClick="rowClick"
:data="scenarioCases"> :data="scenarioCases">
<ms-table-column <ms-table-column
:width="80" :width="80"
:label="$t('commons.id')" :label="$t('commons.id')"
prop="customNum"> prop="customNum">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:label="$t('commons.name')" :label="$t('commons.name')"
prop="name"> prop="name">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:label="$t('test_track.report.list.creator')" :label="$t('test_track.report.list.creator')"
prop="creatorName"/> prop="creatorName"/>
<ms-table-column <ms-table-column
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')"
:width="80"> :width="80">
<template v-slot:default="scope"> <template v-slot:default="scope">
<priority-table-item :value="scope.row.level" ref="priority"/> <priority-table-item :value="scope.row.level" ref="priority"/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:width="70" :width="70"
:label="$t('api_test.automation.step')" :label="$t('api_test.automation.step')"
prop="stepTotal"> prop="stepTotal">
</ms-table-column> </ms-table-column>
<ms-table-column <ms-table-column
:width="80" :width="80"
:label="$t('test_track.plan_view.execute_result')" :label="$t('test_track.plan_view.execute_result')"
prop="lastResult"> prop="lastResult">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<status-table-item v-if="row.lastResult === 'Success'" :value="'Pass'"/> <status-table-item v-if="row.lastResult === 'Success'" :value="'Pass'"/>
<status-table-item v-else-if="row.lastResult === 'Fail'" :value="'Failure'"/> <status-table-item v-else-if="row.lastResult === 'Fail'" :value="'Failure'"/>
<status-table-item v-else-if="row.lastResult === 'STOP'" :value="'STOP'"/> <status-table-item v-else-if="row.lastResult === 'STOP'" :value="'STOP'"/>
<status-table-item v-else-if="row.lastResult === 'Running'" :value="'Underway'"/> <status-table-item v-else-if="row.lastResult === 'Running'" :value="'Underway'"/>
<status-table-item v-else-if="row.lastResult === 'Waiting'" :value="'Waiting'"/> <status-table-item v-else-if="row.lastResult === 'Waiting'" :value="'Waiting'"/>
<status-table-item v-else-if="row.lastResult === 'Timeout'" :value="'Timeout'"/> <status-table-item v-else-if="row.lastResult === 'Timeout'" :value="'Timeout'"/>
<status-table-item v-else :value="'Prepare'"/> <status-table-item v-else-if="row.lastResult === 'errorReportResult'" :value="'ErrorReportResult'"/>
</template> <status-table-item v-else :value="'Prepare'"/>
</ms-table-column> </template>
</ms-table> </ms-table-column>
</el-scrollbar> </ms-table>
</el-card> </el-scrollbar>
</el-card>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<ms-api-report v-if="showResponse" :is-plan="true" :share-id="shareId" :is-share="isShare" :template-report="response" :is-template="isTemplate" :infoDb="true" :report-id="reportId"/> <ms-api-report v-if="showResponse" :is-plan="true" :share-id="shareId" :is-share="isShare"
:template-report="response" :is-template="isTemplate" :infoDb="true" :report-id="reportId"/>
<div class="empty" v-else>{{ $t('test_track.plan.load_case.content_empty') }}</div> <div class="empty" v-else>{{ $t('test_track.plan.load_case.content_empty') }}</div>
</ms-main-container> </ms-main-container>
</el-container> </el-container>
</template> </template>
<script> <script>
@ -70,20 +72,24 @@ import {
getPlanScenarioAllCase, getPlanScenarioAllCase,
getPlanScenarioFailureCase, getPlanScenarioFailureCase,
getSharePlanScenarioAllCase, getSharePlanScenarioAllCase,
getSharePlanScenarioFailureCase getSharePlanScenarioFailureCase,
getPlanScenarioErrorReportCase,
getSharePlanScenarioErrorReportCase,
} from "@/network/test-plan"; } from "@/network/test-plan";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn"; import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import MsApiReport from "@/business/components/api/automation/report/ApiReportDetail"; import MsApiReport from "@/business/components/api/automation/report/ApiReportDetail";
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
export default { export default {
name: "ApiScenarioFailureResult", name: "ApiScenarioFailureResult",
components: { components: {
MsMainContainer, MsMainContainer,
MsAsideContainer, MsAsideContainer,
MsApiReport, MsApiReport,
MsTableColumn, MsTable, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem}, MsTableColumn, MsTable, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem
},
props: { props: {
planId: String, planId: String,
isTemplate: Boolean, isTemplate: Boolean,
@ -91,11 +97,12 @@ export default {
isShare: Boolean, isShare: Boolean,
shareId: String, shareId: String,
isAll: Boolean, isAll: Boolean,
isErrorReport: Boolean,
isDb: Boolean isDb: Boolean
}, },
data() { data() {
return { return {
scenarioCases: [], scenarioCases: [],
result: {}, result: {},
reportId: null, reportId: null,
response: {}, response: {},
@ -115,13 +122,19 @@ export default {
methods: { methods: {
getScenarioApiCase() { getScenarioApiCase() {
if (this.isTemplate || this.isDb) { if (this.isTemplate || this.isDb) {
if (this.isAll) { if(this.isErrorReport){
this.scenarioCases = this.report.errorReportScenarios ? this.report.errorReportScenarios : [];
}else if (this.isAll) {
this.scenarioCases = this.report.scenarioAllCases ? this.report.scenarioAllCases : []; this.scenarioCases = this.report.scenarioAllCases ? this.report.scenarioAllCases : [];
} else { } else {
this.scenarioCases = this.report.scenarioFailureCases ? this.report.scenarioFailureCases : []; this.scenarioCases = this.report.scenarioFailureCases ? this.report.scenarioFailureCases : [];
} }
} else if (this.isShare) { } else if (this.isShare) {
if (this.isAll) { if(this.isErrorReport){
this.result = getSharePlanScenarioErrorReportCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
});
}else if (this.isAll) {
this.result = getSharePlanScenarioAllCase(this.shareId, this.planId, (data) => { this.result = getSharePlanScenarioAllCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data; this.scenarioCases = data;
}); });
@ -131,7 +144,11 @@ export default {
}); });
} }
} else { } else {
if (this.isAll) { if(this.isErrorReport){
this.result = getPlanScenarioErrorReportCase(this.planId, (data) => {
this.scenarioCases = data;
});
}else if (this.isAll) {
this.result = getPlanScenarioAllCase(this.planId, (data) => { this.result = getPlanScenarioAllCase(this.planId, (data) => {
this.scenarioCases = data; this.scenarioCases = data;
}); });

View File

@ -72,11 +72,14 @@ export function getSharePlanFunctionAllCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/case/list/all/' + shareId + '/' + planId, callback) : {}; return planId ? baseGet('/share/test/plan/case/list/all/' + shareId + '/' + planId, callback) : {};
} }
export function getPlanScenarioFailureCase(planId, callback) { export function getPlanScenarioFailureCase(planId, callback) {
return planId ? baseGet('/test/plan/scenario/case/list/failure/' + planId, callback) : {}; return planId ? baseGet('/test/plan/scenario/case/list/failure/' + planId, callback) : {};
} }
export function getPlanScenarioErrorReportCase(planId, callback) {
return planId ? baseGet('/test/plan/scenario/case/list/errorReport/' + planId, callback) : {};
}
export function getPlanScenarioAllCase(planId, callback) { export function getPlanScenarioAllCase(planId, callback) {
return planId ? baseGet('/test/plan/scenario/case/list/all/' + planId, callback) : {}; return planId ? baseGet('/test/plan/scenario/case/list/all/' + planId, callback) : {};
} }
@ -89,10 +92,17 @@ export function getSharePlanScenarioAllCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/scenario/case/list/all/' + shareId + '/' + planId, callback) : {}; return planId ? baseGet('/share/test/plan/scenario/case/list/all/' + shareId + '/' + planId, callback) : {};
} }
export function getSharePlanScenarioErrorReportCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/scenario/case/list/errorReport/' + shareId + '/' + planId, callback) : {};
}
export function getPlanApiFailureCase(planId, callback) { export function getPlanApiFailureCase(planId, callback) {
return planId ? baseGet('/test/plan/api/case/list/failure/' + planId, callback) : {}; return planId ? baseGet('/test/plan/api/case/list/failure/' + planId, callback) : {};
} }
export function getPlanApiErrorReportCase(planId, callback) {
return planId ? baseGet('/test/plan/api/case/list/errorReport/' + planId, callback) : {};
}
export function getPlanApiAllCase(planId, callback) { export function getPlanApiAllCase(planId, callback) {
return planId ? baseGet('/test/plan/api/case/list/all/' + planId, callback) : {}; return planId ? baseGet('/test/plan/api/case/list/all/' + planId, callback) : {};
} }
@ -101,6 +111,10 @@ export function getSharePlanApiFailureCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/api/case/list/failure/' + shareId + '/' + planId, callback) : {}; return planId ? baseGet('/share/test/plan/api/case/list/failure/' + shareId + '/' + planId, callback) : {};
} }
export function getSharePlanApiErrorReportCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/api/case/list/errorReport/' + shareId + '/' + planId, callback) : {};
}
export function getSharePlanApiAllCase(shareId, planId, callback) { export function getSharePlanApiAllCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/api/case/list/all/' + shareId + '/' + planId, callback) : {}; return planId ? baseGet('/share/test/plan/api/case/list/all/' + shareId + '/' + planId, callback) : {};
} }