From 759d067fd7687d287e7af032c0dbbdd6a35d836e Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Mon, 23 Sep 2024 19:54:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=96=AD=E8=A8=80=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BB=BB=E7=84=B6=E6=98=BE=E7=A4=BA=E6=88=90?= =?UTF-8?q?=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046899 --user=陈建星 [接口测试]github#332222个全局断言成功+1个接口用例本身断言失败 = 最终结果为成功 https://www.tapd.cn/55049933/s/1583998 --- .../jmeter/MsCommonElementConverter.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsCommonElementConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsCommonElementConverter.java index 49d20104e2..05ffa6c636 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsCommonElementConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsCommonElementConverter.java @@ -78,11 +78,23 @@ public class MsCommonElementConverter extends AbstractJmeterElementConverter { - assertion.setProjectId(element.getProjectId()); - AssertionConverterFactory.getConverter(assertion.getClass()).parse(tree, assertion, config, isIgnoreAssertStatus(assertions)); - }); + // 将状态码断言放最前面,否则会影响脚本断言的效果,即使脚本断言失败,总状态还是显示成功 + List sortAssertions = new ArrayList<>(assertions.size()); + assertions.forEach(item -> { + if (item instanceof MsResponseCodeAssertion) { + sortAssertions.add(item); + } + }); + assertions.forEach(item -> { + if (!(item instanceof MsResponseCodeAssertion)) { + sortAssertions.add(item); + } + }); + sortAssertions + .forEach(assertion -> { + assertion.setProjectId(element.getProjectId()); + AssertionConverterFactory.getConverter(assertion.getClass()).parse(tree, assertion, config, isIgnoreAssertStatus(assertions)); + }); } /**