BeanShell Assertion in Jmeter
2016-02-15 18:22
573 查看
以下为几个beanshell assertion的栗子:
if (ResponseCode != null && ResponseCode.equals ("200") == false )
{
// this is standard stuff
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 {
String body= new String(ResponseData);
if(!body.contains("pagekey-abook_imported_contacts_to_invite"))
{
Failure= true ;
FailureMessage = "expected pagekey-abook_imported_contacts_to_invite != " + vars.get("pagekey");
print("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
log.warn("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
}
}
或者
String result = vars.getObject("result").get(0).get("mobile");
String actresult = "18XXXX405";
if(result.equals(actresult)){
log.info("注册人的推荐用户测试通过");
} else {
Failure = true;
FailureMessage="注册人的推荐用户测试失败:"+"预期结果为"+actresult+", 实际结果为"+result;
log.info("注册人的推荐用户测试失败:"+"预期结果为"+actresult+", 实际结果为"+result );
}
http://www.beanshell.org
if (ResponseCode != null && ResponseCode.equals ("200") == false )
{
// this is standard stuff
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 {
String body= new String(ResponseData);
if(!body.contains("pagekey-abook_imported_contacts_to_invite"))
{
Failure= true ;
FailureMessage = "expected pagekey-abook_imported_contacts_to_invite != " + vars.get("pagekey");
print("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
log.warn("DisplayImportedContacts failed for ticketId=" + vars.get("polling_id"));
}
}
或者
String result = vars.getObject("result").get(0).get("mobile");
String actresult = "18XXXX405";
if(result.equals(actresult)){
log.info("注册人的推荐用户测试通过");
} else {
Failure = true;
FailureMessage="注册人的推荐用户测试失败:"+"预期结果为"+actresult+", 实际结果为"+result;
log.info("注册人的推荐用户测试失败:"+"预期结果为"+actresult+", 实际结果为"+result );
}
http://www.beanshell.org
相关文章推荐
- Mac系统下创建右键打开Shell的功能
- Linux学习笔记(6)----Bash shell 登陆后配置文件的加载
- CentOS6.x安装shc 3.8.9用于加密shell脚本
- 什么时候不应该使用shell脚本
- hbase shell常用命令总结
- Shell Script
- HBase shell的基本用法
- shell脚本编程总结
- Android shell 脚本
- 【shell脚本小实例 1】测试某个网段内IP连通性
- Linux学习笔记:Shell基础正则表达式
- Linux — Shell
- 抽取数据shell
- Powershell 开机自动加载Snapin 和module
- Shell特殊变量
- Shell变量
- 第一个Shell脚本
- Shell简介
- shell脚本之sed使用----替换、变量、转义字符
- adb shell 不支持Ctrl + C, TAB, DOWN/UP 等按键问题解决方案