fix(测试计划): #1007045 #1007208 【测试跟踪】执行整个测试计划,没有执行接口用例;测试计划手动执行完,状态还是进行中

--bug=1007045 --user=宋天阳 【测试跟踪】执行整个测试计划,没有执行接口用例
https://www.tapd.cn/55049933/s/1059874;--bug=1007208 --user=宋天阳
【测试跟踪】测试计划手动执行完,状态还是进行中 https://www.tapd.cn/55049933/s/1059875
This commit is contained in:
song-tianyang 2021-10-27 16:09:21 +08:00 committed by song-tianyang
parent 09db8fb607
commit 3b5f985b19
4 changed files with 47 additions and 2 deletions

View File

@ -35,4 +35,6 @@ public interface ExtTestPlanMapper {
List<String> findIdByPerformanceReportId(String reportId);
List<TestPlan> listRecent(@Param("userId") String userId, @Param("projectId") String currentProjectId);
int updateActualEndTimeIsNullById(String testPlanID);
}

View File

@ -279,5 +279,9 @@
</where>
order by test_plan.update_time desc
</select>
<update id="updateActualEndTimeIsNullById">
update test_plan
set actual_end_time = null
where id = #{0}
</update>
</mapper>

View File

@ -805,8 +805,9 @@ public class TestPlanReportService {
//更新TestPlan状态为完成
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId());
if (testPlan != null) {
testPlanService.checkStatus(testPlan);
// testPlan.setStatus(TestPlanStatus.Completed.name());
testPlanMapper.updateByPrimaryKeySelective(testPlan);
// testPlanMapper.updateByPrimaryKeySelective(testPlan);
}
if (testPlan != null && StringUtils.equalsAny(report.getTriggerMode(),
ReportTriggerMode.MANUAL.name(),

View File

@ -509,6 +509,43 @@ public class TestPlanService {
}
}
public void checkStatus(TestPlanWithBLOBs testPlanWithBLOBs) { // 检查执行结果自动更新计划状态
List<String> statusList = new ArrayList<>();
statusList.addAll(extTestPlanTestCaseMapper.getExecResultByPlanId(testPlanWithBLOBs.getId()));
statusList.addAll(testPlanApiCaseService.getExecResultByPlanId(testPlanWithBLOBs.getId()));
statusList.addAll(testPlanScenarioCaseService.getExecResultByPlanId(testPlanWithBLOBs.getId()));
statusList.addAll(testPlanLoadCaseService.getStatus(testPlanWithBLOBs.getId()));
if (statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况
testPlanWithBLOBs.setStatus(TestPlanStatus.Prepare.name());
editTestPlan(testPlanWithBLOBs);
return;
}
int passNum = 0, prepareNum = 0, failNum = 0;
for (String res : statusList) {
if (StringUtils.equals(res, TestPlanTestCaseStatus.Pass.name())
|| StringUtils.equals(res, "success")
|| StringUtils.equals(res, ScenarioStatus.Success.name())) {
passNum++;
} else if (res == null || StringUtils.equals(TestPlanStatus.Prepare.name(), res)) {
prepareNum++;
} else {
failNum++;
}
}
if (passNum == statusList.size()) { // 全部通过
testPlanWithBLOBs.setStatus(TestPlanStatus.Completed.name());
this.editTestPlan(testPlanWithBLOBs);
// 发送成功通知
// sendCompletedNotice(testPlanWithBLOBs);
} else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束
testPlanWithBLOBs.setStatus(TestPlanStatus.Finished.name());
editTestPlan(testPlanWithBLOBs);
} else if (prepareNum != 0) { // 进行中
testPlanWithBLOBs.setStatus(TestPlanStatus.Underway.name());
editTestPlan(testPlanWithBLOBs);
}
}
public List<TestPlanDTOWithMetric> listTestPlanByProject(QueryTestPlanRequest request) {
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
return testPlans;
@ -1086,6 +1123,7 @@ public class TestPlanService {
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) {
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
//创建测试报告然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, testPlanID, userId, triggerMode);