fix(接口测试): 修复测试计划的执行数据会被接口统计到的问题

--bug=1019780 --user=宋天阳 【接口测试】首页 - 场景用例数量统计 -
执行次数统计,在测试计划中执行场景也会统计到接口模块 https://www.tapd.cn/55049933/s/1298691
This commit is contained in:
song-tianyang 2022-11-18 19:03:39 +08:00 committed by 建国
parent c66cf14ee8
commit fe254b8e92
6 changed files with 24 additions and 14 deletions

View File

@ -20,9 +20,9 @@ public interface ExtApiScenarioReportMapper {
long countByProjectID(String projectId);
long countByProjectIdAndCreateInThisWeek(@Param("projectId") String projectId, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
long countByProjectIdAndCreateInThisWeek(@Param("projectId") String projectId, @Param("executeType") String executeType, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
long countByProjectIdAndCreateAndByScheduleInThisWeek(@Param("projectId") String projectId, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
long countByProjectIdAndCreateAndByScheduleInThisWeek(@Param("projectId") String projectId, @Param("executeType") String executeType, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
List<ApiDataCountResult> countByProjectIdGroupByExecuteResult(@Param("projectId") String projectId, @Param("version") String version);

View File

@ -362,6 +362,10 @@
<if test="version != null">
AND version = #{version}
</if>
<if test="executeType != null">
AND execute_type = #{executeType}
</if>
</select>
<select id="countByProjectIdAndCreateAndByScheduleInThisWeek" resultType="java.lang.Long">
@ -371,6 +375,9 @@
AND project_id = #{projectId}
<if test="version != null">
AND version = #{version}
</if>
<if test="executeType != null">
AND execute_type = #{executeType}
</if>
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>

View File

@ -144,10 +144,10 @@ public class ApiHomeController {
//统计覆盖率
long dateCountByCreateInThisWeek = apiAutomationService.countScenarioByProjectIDAndCreatInThisWeek(projectId);
apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek);
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, null);
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null);
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
//所有执行次数
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, null);
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, ExecutionExecuteTypeEnum.BASIC.name(), null);
apiCountResult.setExecutedTimes(executedTimes);
//未执行未通过已通过
List<ApiDataCountResult> countResultByRunResult = apiAutomationService.countRunResultByProjectID(projectId);
@ -188,9 +188,9 @@ public class ApiHomeController {
apiCountResult.setTotal(allTaskCount);
long taskCountInThisWeek = baseScheduleService.countTaskByProjectIdInThisWeek(projectId);
apiCountResult.setCreatedInWeek(taskCountInThisWeek);
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, null);
long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null);
apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber);
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), null);
long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), ExecutionExecuteTypeEnum.BASIC.name(), null);
apiCountResult.setExecutedTimes(executedTimes);
//统计 失败 成功 以及总数
List<ApiDataCountResult> allExecuteResult = apiScenarioReportService.countByProjectIdGroupByExecuteResult(projectId, null);
@ -233,7 +233,7 @@ public class ApiHomeController {
@GetMapping("/failure/case/about/plan/{projectId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}")
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable boolean selectFunctionCase,
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
@PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
List<ExecutedCaseInfoResult> selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, selectFunctionCase, limitNumber);

View File

@ -91,7 +91,7 @@ public class ApiScenarioExecutionInfoService {
scenarioExecutionInfoMapper.deleteByExample(example);
}
public long countExecuteTimesByProjectID(String projectId, String triggerMode, String version) {
public long countExecuteTimesByProjectID(String projectId, String triggerMode, String executeType, String version) {
ScenarioExecutionInfoExample example = new ScenarioExecutionInfoExample();
ScenarioExecutionInfoExample.Criteria criteria = example.createCriteria();
criteria.andProjectIdEqualTo(projectId);
@ -101,6 +101,9 @@ public class ApiScenarioExecutionInfoService {
if (StringUtils.isNotEmpty(version)) {
criteria.andVersionEqualTo(version);
}
if (StringUtils.isNotEmpty(executeType)) {
criteria.andExecuteTypeEqualTo(executeType);
}
return scenarioExecutionInfoMapper.countByExample(example);
}

View File

@ -718,7 +718,7 @@ public class ApiScenarioReportService {
return ids;
}
public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId, String version) {
public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId, String executeType, String version) {
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
Date firstTime = startAndEndDateInWeek.get("firstTime");
@ -727,11 +727,11 @@ public class ApiScenarioReportService {
if (firstTime == null || lastTime == null) {
return 0;
} else {
return extApiScenarioReportMapper.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, version, firstTime.getTime(), lastTime.getTime());
return extApiScenarioReportMapper.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, executeType, version, firstTime.getTime(), lastTime.getTime());
}
}
public long countByProjectIdAndCreateInThisWeek(String projectId, String version) {
public long countByProjectIdAndCreateInThisWeek(String projectId, String executeType, String version) {
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
Date firstTime = startAndEndDateInWeek.get("firstTime");
@ -740,7 +740,7 @@ public class ApiScenarioReportService {
if (firstTime == null || lastTime == null) {
return 0;
} else {
return extApiScenarioReportMapper.countByProjectIdAndCreateInThisWeek(projectId, version, firstTime.getTime(), lastTime.getTime());
return extApiScenarioReportMapper.countByProjectIdAndCreateInThisWeek(projectId, executeType, version, firstTime.getTime(), lastTime.getTime());
}
}

View File

@ -2010,8 +2010,8 @@ public class ApiScenarioService {
return result;
}
public long countExecuteTimesByProjectID(String projectId, String triggerMode, String version) {
return scenarioExecutionInfoService.countExecuteTimesByProjectID(projectId, triggerMode, version);
public long countExecuteTimesByProjectID(String projectId, String triggerMode, String executeType, String version) {
return scenarioExecutionInfoService.countExecuteTimesByProjectID(projectId, triggerMode, executeType, version);
}
/**