我的BeanShell断言返回以下结果为错误:的JMeter BeanShell的声明中遇到“\”后“”
Assertion error: true
Assertion failure: false
Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval
Sourced file: inline evaluation of: `` String sentText = \"Changed the TEXT\"; String receivedText = \"Changed the TEXT\"; . . . '' Token Parsing Error: Lexical error at line 2, column 18. Encountered: "\\" (92), after : ""
我已经使用了BeanShell的预处理器设置属性如下,我用它编辑,它工作正常。
${__setProperty(textEdit,\"Changed the TEXT\")}
然后,我使用GET调用获取信息,然后使用以下正则表达式获取特定信息。
\"edittedText\":(\".*?\")}
然后,我使用BeanShell Assertion将该正则表达式的结果放入属性textEditPost中,如下所示。在该BeanShell断言中,我还检查更改后的值是否为新值。
${__setProperty(textEditPost,${textEditPost})}
String sentText = ${__property(textEdit)};
String receivedText = ${__property(textEditPost)};
if (sentText.equals(receivedText))
{
Failure = false;
}
else
{
Failure = true;
FailureMessage = "The Text does not match, expected: " + sentText + " but found: " + receivedText;
}
我完全不知道遇到两个反斜杠的错误来自哪里,因为两个字符串都包含相同的数据。 有没有人有一个想法,为什么发生这种情况和一个可能的解决方案?