loadrunner調用jar包方法
阿新 • • 發佈:2017-05-15
ssp wrap 選擇 col new osc ips 文件 pack
環境
win7(32位)/winXP+loadrunner11+JDK 1.6(一定要配置JAVA環境變量)
1、Eclipse中創建com.medivh包
1 package com.medivh; 2 3 public class HelloWord { 4 public void show(String str){ 5 System.out.println("接收參數:"+str); 6 } 7 }
2、導出JAR包
點擊file-->export-->JAR file-->Next-->選擇com.medivh包-->Finish
3、loadrunner設置
新建Java Vuser
4、導入jar包文件HelloWorld.jar,Run-->time Settings-->classpath加入HelloWorld.jar。
5、編寫腳本如下:
import lrapi.lr; import com.golive.HelloWord; //導入JAR包類 public class Actions { public int init() throws Throwable { return 0; }//end of init public int action() throws Throwable { HelloWord h = new HelloWord(); h.show("nihao"); return 0; }//end of action public int end() throws Throwable { return 0; }//end of end }
6、運行腳本
loadrunner調用jar包方法