refactor(接口测试): 变量断言正则匹配,优化变量不存在报错提示

--bug=1039695 --user=陈建星 【接口测试】定义-断言-值为josn和list断言失败 https://www.tapd.cn/55049933/s/1503406
This commit is contained in:
AgAngle 2024-04-21 15:50:25 +08:00 committed by Craftsman
parent f3330726ec
commit c1a2eeb752
1 changed files with 5 additions and 1 deletions

View File

@ -81,7 +81,11 @@ public class VariableAssertionConverter extends AssertionConverter<MsVariableAss
handleMap.put(MsAssertionCondition.REGEX.name(), handleMap.put(MsAssertionCondition.REGEX.name(),
""" """
import java.util.regex.Pattern; import java.util.regex.Pattern;
result = Pattern.matches(Pattern.quote(expectation), variableValue); if (variableValue != null) {
result = Pattern.matches(Pattern.quote(expectation), variableValue);
} else {
result = false;
}
msg = variableValue + " not matching " + expectation; msg = variableValue + " not matching " + expectation;
"""); """);