fix(接口测试): 变量断言期望值中带有特殊符号,断言失败

--bug=1037889 --user=陈建星 【项目环境】环境管理-断言中添加变量断言-断言匹配包含json格式时,断言错误 https://www.tapd.cn/55049933/s/1497938
This commit is contained in:
AgAngle 2024-04-16 11:06:01 +08:00 committed by Craftsman
parent 3748463caf
commit ccb11753f3
1 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.plugin.api.dto.ParameterConfig;
import io.metersphere.sdk.constants.MsAssertionCondition; import io.metersphere.sdk.constants.MsAssertionCondition;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.jmeter.assertions.JSR223Assertion; import org.apache.jmeter.assertions.JSR223Assertion;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
@ -75,7 +76,7 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
variableValue = vars.get("%s"); variableValue = vars.get("%s");
expectation = "%s"; expectation = "%s";
flag = true; flag = true;
""", variableAssertionItem.getVariableName(), variableAssertionItem.getExpectedValue()); """, StringEscapeUtils.escapeJava(variableAssertionItem.getVariableName()), StringEscapeUtils.escapeJava(variableAssertionItem.getExpectedValue())); // 转义一下再填充
handleMap.put(MsAssertionCondition.REGEX.name(), handleMap.put(MsAssertionCondition.REGEX.name(),
""" """