loadrunner调用jar包方法

环境

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
}

原文地址:https://www.cnblogs.com/medivhxu/p/6856745.html