fix(测试跟踪): 修复执行测试计划后状态错误
--bug=1015942 --user=刘瑶 【测试跟踪】github#16977,在测试计划列表列表中点击【执行】,完成执行后。该计划当前状态不对:测试进度非100%,但是当前状态为“完成”。 https://www.tapd.cn/55049933/s/1231292 Closes#16977
This commit is contained in:
parent
c9c174cc68
commit
cd8c3be96e
|
@ -30,6 +30,7 @@ import javax.annotation.Resource;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
|
@ -61,8 +62,10 @@ public class TestPlanMessageService {
|
|||
if (!report.getIsApiCaseExecuting() && !report.getIsPerformanceExecuting() && !report.getIsScenarioExecuting()) {
|
||||
//更新TestPlan状态为完成
|
||||
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId());
|
||||
if (testPlan != null && !StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
|
||||
testPlan.setStatus(TestPlanStatus.Completed.name());
|
||||
if (testPlan != null
|
||||
&& !StringUtils.equalsAny(testPlan.getStatus(), TestPlanStatus.Completed.name(), TestPlanStatus.Finished.name())) {
|
||||
|
||||
testPlan.setStatus(calcTestPlanStatusWithPassRate(testPlan));
|
||||
testPlanService.editTestPlan(testPlan);
|
||||
}
|
||||
try {
|
||||
|
@ -80,6 +83,27 @@ public class TestPlanMessageService {
|
|||
}
|
||||
}
|
||||
|
||||
public String calcTestPlanStatusWithPassRate(TestPlanWithBLOBs testPlan) {
|
||||
try {
|
||||
// 计算通过率
|
||||
TestPlanDTOWithMetric testPlanDTOWithMetric = BeanUtils.copyBean(new TestPlanDTOWithMetric(), testPlan);
|
||||
testPlanService.calcTestPlanRate(Collections.singletonList(testPlanDTOWithMetric));
|
||||
//测试进度
|
||||
Double testRate = Optional.ofNullable(testPlanDTOWithMetric.getTestRate()).orElse(0.0);
|
||||
//通过率
|
||||
Double passRate = Optional.ofNullable(testPlanDTOWithMetric.getPassRate()).orElse(0.0);
|
||||
|
||||
//只有通过率 与 测试进度 都为100% 才为已完成状态
|
||||
if (testRate >= 100 && passRate >= 100) {
|
||||
return TestPlanStatus.Completed.name();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("计算通过率失败!", e);
|
||||
}
|
||||
|
||||
return TestPlanStatus.Finished.name();
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendMessage(TestPlan testPlan, TestPlanReport testPlanReport, String projectId) {
|
||||
assert testPlan != null;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 830bad0961b3ec2eaff21e9eac382d16f0521639
|
||||
Subproject commit 2ca4ff0b6d771d280eba6958345426e56d1d15a4
|
|
@ -1 +1 @@
|
|||
Subproject commit 12370ba86adfdf31b11a30d48a59c3715490b351
|
||||
Subproject commit be7591f7f5077a77ee5abce16461af30f3ac8666
|
Loading…
Reference in New Issue