主要的背景就是想学习一下Loadrunner,之后买了一本书,就每天按着书上面去动手操作,想到做笔记的时候,就已经看到参数化这里了,所以第一篇就从参数化这里开始写吧。我们生成的Script,脚本中的数据是固定不变的,只有借助参数化才能模拟真实的场景。
1、步骤
a、首先确定脚本中需要被参数化的数据,数据的实际情况可能是一个,也可能是多个。
b、选中数据,鼠标右键选择替换为参数"Replace with Parameter" ->"Create New Parameter",在弹出的对话框中选择参数类型,并对参数命名,参数的命名一定要便于理解,一下就能看出参数的用途,就和写脚本里面的方法一样。
c、选中数据鼠标右键查看参数列表"Replace with Parameter" -> "Update Values on"中设置参数的取值和参数的更新方式
2、设置参数的取值和参数的更新方式
选中参数点击鼠标右键进入"Parameter Properties"

参数设置有四种方式:
第一种:直接添加行Add Row 或列Add Colum的方式,需要逐个添加,比较繁琐。
第二种:把数据存在记事本中,单击参数设置区域左下角"Edit with Notepad"按钮,比较直观,使用率较多。
第三种:选择导入参数,单击区域左下角data wizard按钮,他是从外部文件导入,数据之间格式要求较为严格。
第四种:选择模拟参数,单击区域右下角"Simulate Parameter",模拟数据,用于判断参数取值方式是否符合预期。


划重点了,取值方式(select next row),我觉得这个还是比较重要的

Sequential:顺序取值,表示此参数从第一行开始取值,依次取后面的每一行;
Random:随机取值,表示每次取得值都是随机取值,有重复的可能;
Unique:唯一取值,按Vuser分配的参数要求和自身的取值规则进行取值;
取值方式,更新值得时间(Update Values on),也包括三个固定选项

Each iteration:循环取值,参数在同一个脚本中取相同的值
Each 0ccurrence:每次遇到就取新值,该参数在同一个脚本中出现两次或两次以上,都会选择按照下一行的方式重新取值
Once:无论参数出现几次,按照选中下一行的方式,只去一次
选择Sequential + Each iteration


选择Sequential + Each 0ccurrence


选择Sequential + Once


如何才能让两个参数的关系不受取值方式的制约?只需要让他们的数据来自同一个数据文件,例如username和password
修改File的数据来源,在新的数据文件下增加password列名

使用快捷键Ctrl+L打开Parameter List窗口,设置以下

运行...............................................................了
选择Sequential + Each iteration、Sequential + Each 0ccurrence

Unuqe取值规则受到when out of values影响,select next row 选择 Unuqe

Abort Vuser:当超出参数取值范围,则终止取值

Continue in a cycle manner:超出参数索引范围后重新循环取值
Continue with last value:超出参数索引范围后一直取最后一个值
网友评论