From b0ff13917c8cbcd02a5d591f759356d8931c3b36 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 25 Jan 2021 17:09:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1=E4=B8=8D=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestPlanLoadCaseService.java | 4 ++++ .../metersphere/track/service/TestPlanService.java | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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()));