故障消息仅适用于jmeter中的故障情况

时间:2017-09-12 06:19:23

标签: java netbeans jmeter assertions beanshell

我在脚本中添加了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";
}

我只有在案件失败时才需要收到失败消息。请告诉我,怎么做?

1 个答案:

答案 0 :(得分:1)

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

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";
    }
}

BTW使用应该使用变量名称的Java约定应该以小写字母开头:failure而不是Failure