From df5e422b665ee99611897a7cdd4247662d330bb1 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 18 Jan 2022 18:08:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E5=9C=BA=E6=99=AF):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=9C=BA=E6=99=AF=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=B6=E6=8E=A7=E5=88=B6=E5=8F=B0=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复接口场景调试时控制台为空的问题 --- .../io/metersphere/api/jmeter/MsDebugListener.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java b/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java index 6b8c6355ca..3f4affe895 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/MsDebugListener.java @@ -162,18 +162,23 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi if (StringUtils.isNotEmpty(requestResult.getName()) && requestResult.getName().startsWith("Transaction=")) { requestResult.getSubRequestResults().forEach(transactionResult -> { transactionResult.getResponseResult().setConsole(console); - dto.setContent("result_" + JSON.toJSONString(transactionResult)); + //解析误报内容 + ErrorReportLibraryParseDTO errorCodeDTO = ErrorReportLibraryUtil.parseAssertions(transactionResult); + JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(transactionResult)); + if(CollectionUtils.isNotEmpty(errorCodeDTO.getErrorCodeList())){ + requestResultObject.put("errorReportResult",errorCodeDTO.getErrorCodeStr()); + } + dto.setContent("result_" + JSON.toJSONString(requestResultObject)); WebSocketUtils.sendMessageSingle(dto); }); } else { + requestResult.getResponseResult().setConsole(console); //解析误报内容 - JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(requestResult)); ErrorReportLibraryParseDTO errorCodeDTO = ErrorReportLibraryUtil.parseAssertions(requestResult); + JSONObject requestResultObject = JSONObject.parseObject(JSON.toJSONString(requestResult)); if(CollectionUtils.isNotEmpty(errorCodeDTO.getErrorCodeList())){ requestResultObject.put("errorReportResult",errorCodeDTO.getErrorCodeStr()); } - - requestResult.getResponseResult().setConsole(console); dto.setContent("result_" + JSON.toJSONString(requestResultObject)); WebSocketUtils.sendMessageSingle(dto); }