测试脚本:
Action() { int i=0; //循环10次 ,输出变量的值 for(i;i<=10;i++){ lr_output_message("%s",lr_eval_string("{parameterized}")); } return 0; }
参数列表个数为5:
参数化配置之如何取值(select next row):
1、select next row:Sequential(按顺序选择下一行,当递归到最后一个参数后,从第一个参数开始重新递归)
代码执行结果:
Starting iteration 1.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Ending action Action.
Ending iteration 1.
2、select next row:Random(随机值,从参数列表中随机选取值)
代码执行结果:
Starting iteration 1.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value3
Action.c(7): Value5
Action.c(7): Value3
Action.c(7): Value1
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Action.c(7): Value3
Ending action Action.
Ending iteration 1.
3、select next row:Unique(唯一值,按顺序选择下一行,当递归到最后一个参数后,LoadRunner直接报错)
代码执行结果:
Starting iteration 1.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Action.c(7): Error: Parameter 'parameterized': No more unique values for this parameter in table 'parameterized.dat' [unique range is 1-5].The parameter continues with last value of the range according to "When Out Of Values" policy.
Action.c(7): Value5
Action.c(7): Error: Parameter 'parameterized': No more unique values for this parameter in table 'parameterized.dat' [unique range is 1-5].The parameter continues with last value of the range according to "When Out Of Values" policy.
Action.c(7): Value5
Action.c(7): Error: Parameter 'parameterized': No more unique values for this parameter in table 'parameterized.dat' [unique range is 1-5].The parameter continues with last value of the range according to "When Out Of Values" policy.
Action.c(7): Value5
Action.c(7): Error: Parameter 'parameterized': No more unique values for this parameter in table 'parameterized.dat' [unique range is 1-5].The parameter continues with last value of the range according to "When Out Of Values" policy.
Action.c(7): Value5
Action.c(7): Error: Parameter 'parameterized': No more unique values for this parameter in table 'parameterized.dat' [unique range is 1-5].The parameter continues with last value of the range according to "When Out Of Values" policy.
Action.c(7): Value5
Ending action Action.
Ending iteration 1
参数化配置之何时取值(update value on):
1、update value on:each iteration(每次迭代的时候取值,在同一个迭代中,无论读多少次,获得的都是同一个参数值)
代码执行结果:
Starting iteration 1.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Action.c(7): Value2
Ending action Action.
Ending iteration 2.
2、update value on:each occurrence(只要取一次,就要新的)
代码执行结果:
Starting iteration 1.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Action.c(7): Value1
Action.c(7): Value2
Action.c(7): Value3
Action.c(7): Value4
Action.c(7): Value5
Ending action Action.
Ending iteration 2.
3、update value on:once(在所有循环中都使用同一个值)
代码执行结果:
Starting iteration 1.Starting action Action.
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Action.c(7): Value1
Ending action Action.
Ending iteration 2.