loadrunner 参数化取值方式详解

本文详细介绍了LoadRunner中的参数化取值方式,包括Sequential、Random、Unique三种方式,以及Each iteration、Each occurrence、Once三个更新选项。通过登录接口的示例,展示了不同组合下的参数取值结果,并探讨了当参数值不足时的处理策略。
摘要由CSDN通过智能技术生成

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

 

改变参数化的取值方式,关键在于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: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 ov
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值