👉 ✈手机屏幕横着看更精彩 *_*. . . . . . 大 江 东 去,浪 淘 尽, 千 古 风 流 人 物。 故 垒 西 边, 人 道 是, 三 国 周 郎 赤 壁。 乱 石 穿 空, 惊 涛 拍 岸, 卷 起 千 堆 雪。 江 山 如 画, 一 时 多 少 豪 杰。 遥 想 公 瑾 当 年, 小 乔 初 嫁 了, 雄 姿 英 发。 羽 扇 纶 巾, 谈 笑 间, 樯 橹 灰 飞 烟 灭。 故 国 神 游, 多 情 应 笑 我, 早 生 华 发。 人 生 如 梦, 一 尊 还 酹 江 月。 (。_°)☆\(- – ) 👈

loadrunner 参数化取值方式详解

参数化对话框中与参数取值方式有关的区域如下,在忘记的时候保存下来,以便于即使查看。

 

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

  Select next row包括以下选项:

  • Sequential:顺序方式
  • Random:随机方式
  • Unique:唯一方式

  Update value on包括如下选项:

  • Each iteration:每次迭代更新取值
  • Each occurrence:每次取值更新
  • Once:只更新一次

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

1
2
3
4
5
6
7
8
9
10
lr_output_message("login_username:%s",lr_eval_string("{login_username}"));<br><br>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:13141140050
Action.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 iteration 1.
Starting iteration 2.
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:13141140050
Action.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 iteration 2.
Starting iteration 3.
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:13141140050
Action.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 iteration 3.
复制代码

第三种取值方式: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: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.
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 2.
Starting iteration 3.
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.
复制代码

第四种取值方式: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: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 1.
Starting iteration 2.
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 2.
Starting iteration 3.
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 3.
复制代码

第五种取值方式: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:13141140050
Action.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 iteration 1.
Starting iteration 2.
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:13141140050
Action.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 iteration 2.
Starting iteration 3.
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:13141140050
Action.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 iteration 3.
复制代码

第六种取值方式: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: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.
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 2.
Starting iteration 3.
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.
复制代码

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

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

当值不足时,可以选择以下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: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.
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:13141140050
Action.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 iteration 1.
Starting iteration 2.
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 called from an 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: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.
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 2.
Starting iteration 3.
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.
复制代码

 

总结:

 本文转载于:loadrunner 参数化取值方式详解

posted @ 2020-11-05 16:16  S-Gavin  阅读(613)  评论(0编辑  收藏  举报