loadrunner java jar包_loadrunner11中java vuser引用jar包

1.创建工程,新建类,HelloWorld.java,代码如下:

48304ba5e6f9fe08f3fa1abda7d326ab.png

1 package com.liuke;

2

3

4

5 public class HelloWorld {

6

7 public String getHello(){

8

9 return "调用自定义函数getHello()";

10

11 }

12

13 public static void main(String[] args) {

14

15 System. out .println("恭喜你调用静态main函数成功");

16

17 }

18

19 }

48304ba5e6f9fe08f3fa1abda7d326ab.png

2、导出jar包并命名为HelloWorld.jar

3、将新生成的jar包HelloWorld.jar放到一个指定的目录下,如D:\LoadRunner\jar。

4、新建Virtual User:选Java Vuser

5、导入jar包文件HelloWorld.jar,Run-time Settings--classpath加入HelloWorld.jar。

6、写脚本,代码如下:

48304ba5e6f9fe08f3fa1abda7d326ab.png

1 import lrapi.lr;

2

3 import com.lkf.HelloWorld;

4

5

6

7 public class Actions

8

9 {

10

11

12

13 public int init() throws Throwable {

14

15 return 0;

16

17 }//end of init

18

19 public int action() throws Throwable {

20

21 //调用自定义函数getHello()

22

23 HelloWorld h = new HelloWorld();

24

25 System.out.println(h.getHello());

26

27 //调用静态系统main函数

28

29 HelloWorld.main(null);

30

31 return 0;

32

33 }//end of action

34

35 public int end() throws Throwable {

36

37 return 0;

38

39 }//end of end

40

41 }

48304ba5e6f9fe08f3fa1abda7d326ab.png

7、运行脚本结果,看到如下输出结果,说明脚本运行成功了

System. out:调用自定义函数getHello()

System. out:恭喜你调用静态main函数成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值