软件测试论坛

 找回密码
 软件测试论坛注册页
查看: 1095|回复: 0

[英文资料] How to generate a unique input in loadrunner?

[复制链接]
发表于 2011-3-16 11:28:06 | 显示全部楼层 |阅读模式
软件测试工程师就业班马上开班
Description:
In the below figure we need to input unique values for the Username. How can we make sure that every username is unique during thousand iterations run?

Solution:
Controller will assign a unique VuserId to every Vuser when we start to run a Vuser. The following is two solutions we can use.
1.        VuserId + iteration No
2.        VuserId + Current Time (If name will be created twice in one iteration)
Code:
Action()
{
        //declare variables
        char testname[100];   
        char *VuserId;
        //create a VuserId type parameter named RunningVuserId in Parameter list
        VuserId=lr_eval_string("{RunningVuserId}");
//The value saved in ParamTimeStamp is the number of milliseconds since midnight January // 1st, 1970.
        web_save_timestamp_param("ParamTimeStamp", LAST);
    //Create testname as format: VuserId_ ParamTimeStamp.
        strcpy(testname,VuserId);
        strcat(testname,"_");
        strcat(testname,lr_eval_string("{ParamTimeStamp}"));
   
        lr_save_string(testname,"UniqueTestname");
lr_output_message("the value is %s", lr_eval_string("{UniqueTestname}"));
return 0;
}

本版积分规则

Archiver|手机版|小黑屋|领测软件测试网 ( 京ICP备10010545号-5 )

GMT+8, 2020-11-29 04:56 , Processed in 0.151787 second(s), 10 queries , Xcache On.

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表