失败消息仅适用于 jmeter 中的失败案例

Failure Message only for failing cases in jmeter

我在脚本中添加了 bean shell 断言。

它显示所有案例的失败消息,即使它通过了。

下面是我的脚本

String response = new String(ResponseData);
if(${BoolValue} == true)
{
    Failure = !(response.contains("growth"));
    FailureMessage = "Projection values is showing in the response data for non-skill reports";

}
if(${BoolValue} == false)
{
    Failure = (response.contains("growth"));
    FailureMessage = "Projection values is not showing in the response data for skill reports";
}

仅当案例失败时我才需要获取失败消息。请让我知道,该怎么做?

在失败消息分配之前检查失败:

String response = new String(ResponseData);
if(${BoolValue} == true)
{
    Failure = !(response.contains("growth"));
    if (Failure) {
      FailureMessage = "Projection values is showing in the response data for non-skill reports";
    }

}
if(${BoolValue} == false)
{
    Failure = (response.contains("growth"));
    if (Failure) {
      FailureMessage = "Projection values is not showing in the response data for skill reports";
    }
}

顺便说一句,应该使用 Java 变量名约定应以小写字母开头,如:failure 而不是 Failure.