【问题标题】:Failure Message only for failing cases in jmeter仅针对 jmeter 中的失败案例的失败消息
【发布时间】:2017-09-12 06:19:22
【问题描述】:

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

仅当案例失败时,我才需要获取失败消息。请告诉我,如何做到这一点?

【问题讨论】:

    标签: java netbeans jmeter assertions beanshell


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      • 2013-11-23
      • 1970-01-01
      相关资源
      最近更新 更多