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

  • 相关阅读:
    docker (centOS 7) 使用笔记3
    docker (centOS 7) 使用笔记4
    docker (centOS 7) 使用笔记2
    docker (centOS 7) 使用笔记1
    docker (centOS 7) 使用笔记3
    CentOS7 修改时区、charset
    p12(PKCS12)和jks互相转换
    tomcat7 日志设置为log4j
    Redis概述与基本操作
    Django学习笔记之安全
  • 原文地址:https://www.cnblogs.com/yingchen/p/5191142.html
Copyright © 2011-2022 走看看