zoukankan      html  css  js  c++  java
  • LoadRunner + java脚本 第三章

    1.Java Vuser 模板脚本如下:

    /*
     * LoadRunner Java script. (Build: _build_number_)
     * 
     * Script Description: 
     *                     
     */
    
    import java.util.HashMap;
    
    import com.Interface.FilmNews;
    import com.Interface.Plans;
    import com.vug.Vug;
    
    import lrapi.web;
    import lrapi.lr;
    
    public class Actions
    {
    	public static String uid = "ko";
    	public static String Md5Key = "jj";
    	public static String filmHost = "http://115.28.1/cias_web/server";
    	public static String planHost = "http://115.28.1/order/server";
    
    	HashMap<String, String> params;
    	Vug vug; // 构建生成url
    	FilmNews fn; // 影讯接口
    	Plans pn; //订单接口
    
    	public int init() throws Throwable {
    	    vug = new Vug(uid, Md5Key);
    	    params = new HashMap<String, String>();
    	    fn = new FilmNews(uid);
    //	    pn = new Plans(uid);
    	    return 0;
    	}//end of init
    
    
    	public int action() throws Throwable {
    
    	    	params = fn.cinemas(); // 要测试的接口
    
    		String url = vug.getURL(filmHost, params);
    
    		lr.start_transaction("test");
    
    		lr.think_time(1); 
    
    		web.reg_find("Text=errCode":0", 
    
    		new String[]{ 
    
    		    "SaveCount=errCode", 
    
    		    web.LAST 
    
    		}); 
    
    		web.reg_save_param("all", 
    
    		new String []{ 
    
    		    "LB={"cinemaId":",  
    
    		    "RB=,", 
    
    		    "Search=Body",
    		    
    		    "ORD=ALL",
    
    		    "LAST"}); 
    
    
    		web.url("test",
    
    		"URL=" + url,
    
    		new String[] {
    
    		    "TargetFrame=",
    
    		    "Resource=0",
    
    		    "RecContentType=text/html",
    
    		    "Mode=HTML",
    
    		    "LAST"
    
    		});
    		
    /*		params = pn.orderadd("<test>", "<test1>", "<test2>");
    		url = vug.getURL(host, params);
    
    		web.url("test",
    
    		"URL=" + url,
    
    		new String[] {
    
    		    "TargetFrame=",
    
    		    "Resource=0",
    
    		    "RecContentType=text/html",
    
    		    "Mode=HTML",
    
    		    "LAST"
    
    		});
    */		
    
    		if (lr.eval_int("<errCode>") == 1 ) {
    
    		    lr.end_transaction("test", lr.PASS);
    			
    		} else {		    
    		    lr.error_message(lr.eval_string("<all_1>"));
    		    lr.end_transaction("test", lr.FAIL);
    		}
    		return 0;
    	}//end of action
    
    
    	public int end() throws Throwable {
    		return 0;
    	}//end of end
    }
    

     2.上述脚本在Controller中测试通过,另LR11的最多支持1000java vuser虚拟用户,License如下:
    golba-100: AEAMAUIK-YAFEKEKJJKEEA-BCJGI
    golba-1000:AEACFSJI-YASEKJJKEAHJD-BCLBR
    web-10000: AEABEXFR-YTIEKEKJJMFKEKEKWBRAUNQJU-KBYGB

  • 相关阅读:
    谈Vite在Electron环境下吃花卷拉馒头的现象
    公司只提供签名服务,不提供证书文件,如何打包Electron应用
    vue3微前端架构——基于蚂蚁qiankun框架
    Vite ❤ Electron——基于Vite搭建Electron+Vue3的开发环境【一】
    dotnet core 高CPU lldb篇
    Openshift入门(转)
    使用 dotnet test 和 xUnit 在 .NET Core 中进行 C# 单元测试
    ASP.NET Core 中的单元测试控制器逻辑
    ASP.NET Core 中间件
    Precise Computation of CLR Object Size
  • 原文地址:https://www.cnblogs.com/mayibanjiah/p/4821622.html
Copyright © 2011-2022 走看看