Jmeter的BeanShell断言

1、什么是BeanShell断言?

      BeanShell断言可以使用beanshell脚本来执行断言检查,可以用于更复杂的个性化需求,使用更灵活,功能更强大,但是要能够熟练使用beanshell脚本。

      在这里除了可以使用beanshell的内置变量外,主要通过Failure和FailureMessage来设置断言结果。

Failure = false;-----表示断言成功,

FailureMessage = "……"; ----自定义的成功信息

Failure = true;-----表示断言失败,

FailureMessage = "……";-----自定义的失败信息。
      下面看一个简单的示例:

其中脚本内容如下:

if ("200".equals(""+ResponseCode) == false )
{
// 响应码不等于200时,设置断言失败,并输出失败信息
Failure=true ;
FailureMessage ="Response code was not a 200 response code it was " + ResponseCode + "." ;
print ( "the return code is " + ResponseCode); // this goes to stdout
log.warn( "the return code is " + ResponseCode); // this goes to the JMeter log file
} else {
// 响应码等于200时,设置断言成功,并输出成功信息
Failure=false;
FailureMessage = "Return true, and the response code was " + ResponseCode;
}
}
————————————————
版权声明:本文为CSDN博主「媛测」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lijing742180/article/details/81157947

posted @ 2020-03-05 16:33  疯狂牙膏  阅读(505)  评论(0编辑  收藏  举报