zoukankan      html  css  js  c++  java
  • BeanShell Assertion in Jmeter

    以下为几个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

  • 相关阅读:
    保证在浏览器上word/图片/Excel的下载的表现形式一样
    C学习笔记 知识集锦(二)
    函数返回值
    C++ 四种新式类型转换
    构造&析构
    指针与引用
    C++三大特性 封装 继承 多态
    Git stash 常见用法
    Git branch && Git checkout常见用法
    linux Vi使用
  • 原文地址:https://www.cnblogs.com/yingchen/p/5191142.html
Copyright © 2011-2022 走看看