loadrunner java 参数化_loadrunner 参数化取值方式详解

参数化对话框中与参数取值方式有关的区域如下:

4e2b77c807f1f400014552fb9e5598f2.png

改变参数化的取值方式,关键在于Select next row和Update value on这两个选项。

Select next row包括以下选项:

Sequential:顺序方式

Random:随机方式

Unique:唯一方式

Update value on包括如下选项:

Each iteration:每次迭代更新取值

Each occurrence:每次取值更新

Once:只更新一次

以下代码以登录接口和参数化进行演示,参数化文件中有2个值

lr_output_message("login_username:%s",lr_eval_string("{login_username}"));

web_custom_request("login",

"URL=http://192.168.44.130:8080/mobile/api/user/login",

"Method=POST",

"TargetFrame=",

"Resource=0",

"Referer=",

"Mode=HTTP",

"EncType=application/json;charset=utf-8",

"Body={\"mobile\":\"{login_username}\",\"password\":\"123456\"}",

LAST);

参数化文件中的数据为:

13141140050

13141140058

第一种取值方式:Sequential+Each iteration,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server: 6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050

Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration 1.

Starting iteration 2.

Notify: Next row for parameter login_username = 2 [table = login_username].

Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140058"

Action.c(18): login_username:13141140058

Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"

Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration 2.

Starting iteration 3.

Notify: Next row for parameter login_username = 1 [table = login_username].

Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050

Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration 3.

第二种取值方式:Sequential+Each occurrence,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Notify: Next row for parameter login_username = 1 [table =login_username].

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Starting action Action.

Action.c(18): Notify: Next row for parameter login_username = 1 [table =login_username].

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

第三种取值方式:Sequential+Once,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

第四种取值方式:Random+Each iteration,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140058"

Action.c(18): login_username:13141140058Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Notify: Next rowfor parameter login_username = 1 [table =login_username].

Notify: Gettingnew value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Notify: Next rowfor parameter login_username = 2 [table =login_username].

Notify: Gettingnew value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140058"

Action.c(18): login_username:13141140058Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

第五种取值方式:Random+Each occurrence,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Notify: Next row for parameter login_username = 1 [table =login_username].

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Starting action Action.

Action.c(18): Notify: Next row for parameter login_username = 1 [table =login_username].

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

第六种取值方式:Random+Once,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

第七种取值方式:Unique+Each iteration

这种取值方式,又可以有以下几种设置:

caad688b1af9d6663fa98e1f1b372d56.png

当值不足时,可以选择以下3种方式:

1)、中断虚拟用户

2)、循环取参数中的值,返回到第一行取值

3)、取最后一行值

以下运行结果以Abort Vuser为例执行,其它情况可自行设置运行,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Notify: Next rowfor parameter login_username = 2 [table =login_username].

Notify: Gettingnew value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140058"

Action.c(18): login_username:13141140058Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Error: Parameter'login_username': No more unique values for this parameter in table 'login_username.dat' [unique range is 1-2]. The Vuser is aborted according to "When Out Of Values"policy.

Action was aborted.

Ending Vuser...

第八种取值方式:Unique+Each occurrence,参数不够用时,也会报错,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Next row for parameter login_username = 2 [table =login_username].

Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Error: Parameter 'login_username': No more unique values for this parameter in table 'login_username.dat' [unique range is 1-2]. The Vuser is aborted according to "When Out Of Values"policy.

Abort was calledfroman action.

Ending Vuser...

第九种取值方式:Unique+Once,参数不够用时,也会报错,设置迭代次数为3次,参数取值结果为:

Starting iteration 1.

Maximum number of concurrent connections per server:6 [MsgId: MMSG-26989]

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration1.

Starting iteration2.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration2.

Starting iteration3.

Starting action Action.

Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"

Action.c(18): login_username:13141140050Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]

Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]

Ending action Action.

Ending iteration3.

总结:

00bf0606b8cca0984efbf574cfeb85d7.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值