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
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM