loadrunner学习之lr_eval_string()函数
上一篇 /
下一篇 2013-10-10 15:56:07
/ 个人分类:loadrunner
之前一直未深入研究过loadrunner的函数,今天先了解了一下lr_eval_string()函数的应用,该函数是将loadrunner变量的当前值提取出来供使用。
lr_eval_string()函数的主要作用:返回脚本中的一个参数当前的值,返回值类型:char
一般多用在调试脚本时输出参数的值.具体用法如下:
lr_output_message("The parameter1's value is %s",lr_eval_string("{parameter1}")),其中参数parameter1在之前已经定义了的参数
lr_log_message(lr_eval_string("{parameter1}"))
单看理论知识不是很清楚,因此做了一个实践练习,如下:
Action()
{
char *testStr="{NewParam}";
char a[10];
strcpy(a,"{NewParam}");
lr_output_message("+++++测试结果1:+++++");
lr_output_message("{NewParam}");
lr_output_message(lr_eval_string("{NewParam}"));
lr_output_message("+++++测试结果2:+++++");
lr_output_message(testStr);
lr_output_message(lr_eval_string(testStr));
lr_output_message("+++++测试结果3:+++++");
lr_output_message(a);
lr_output_message(lr_eval_string(a));
return 0;
}
其中,{NewParam}的第一个值为aaa;
运行结果为:
Action.c(10): +++++测试结果1:+++++
Action.c(12): {NewParam}
Action.c(14): aaa
Action.c(17): +++++测试结果2:+++++
Action.c(19): {NewParam}
Action.c(21): aaa
Action.c(24): +++++测试结果3:+++++
Action.c(26): {NewParam}
Action.c(28): aaa
综上,若是在使用变量时,若不调用lr_eval_string()函数时,则所取到的为变量的名称,不是变量当前值;
目前,对该函数仅了解这一点,还需对其进行深入研究;
收藏
举报
TAG: