diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java index b1a9fd0f7f..f3bca8a613 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java @@ -139,4 +139,8 @@ public class TestPlanLoadCaseService { testPlanLoadCaseMapper.updateByPrimaryKeySelective(testPlanLoadCase); } } + + public List getStatus(String planId) { + return extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId); + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 0bede56d14..fe0d58e77d 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -382,7 +382,17 @@ public class TestPlanService { } }); - testPlan.setTotal(apiExecResults.size() + scenarioExecResults.size() + functionalExecResults.size()); + List loadResults = testPlanLoadCaseService.getStatus(testPlan.getId()); + loadResults.forEach(item -> { + if (StringUtils.isNotBlank(item)) { + testPlan.setTested(testPlan.getTested() + 1); + if (StringUtils.equals(item, "success")) { + testPlan.setPassed(testPlan.getPassed() + 1); + } + } + }); + + testPlan.setTotal(apiExecResults.size() + scenarioExecResults.size() + functionalExecResults.size() + loadResults.size()); testPlan.setPassRate(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTested())); testPlan.setTestRate(MathUtils.getPercentWithDecimal(testPlan.getTotal() == 0 ? 0 : testPlan.getTested() * 1.0 / testPlan.getTotal()));