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

  • 相关阅读:
    宿主机无法访问CentOS7上Jenkins服务的解决办法
    415. Add Strings
    367. Valid Perfect Square
    326. Power of Three
    258. Add Digits
    231. Power of Two
    204. Count Primes
    202. Happy Number
    172. Factorial Trailing Zeroes
    171. Excel Sheet Column Number
  • 原文地址:https://www.cnblogs.com/yingchen/p/5191142.html
Copyright © 2011-2022 走看看