环境
win7(32位)/winXP+loadrunner11+JDK 1.6(一定要配置JAVA环境变量)
1、Eclipse中创建com.medivh包
package com.medivh; public class HelloWord {
public void show(String str){
System.out.println("接收参数:"+str);
}
}
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 ;
}//end of init public int action() throws Throwable {
HelloWord h = new HelloWord();
h.show("nihao");
return ;
}//end of action public int end() throws Throwable {
return ;
}//end of end
}
6、运行脚本