Thursday

use script to validate an action in LoadRunner

Have you ever wanted to keep track of things when it is done or when an action is performed in your loadrunner script? Well that’s where Update datapoint function comes in.

I have had to use this function over and over again in my day to day scripting and therefore i would like to add it here for those of you who are struggling to get things done or looking for a script like this to make your life easier.

Well for those of you who are not familiar with loadrunner, It is a performance testing tool that is used to emulate high load of users performing various actions on a particular site. This will give the business a better understanding of cpacity and help in capacity planning.

FUNCTION

int updateDataPoint(int currentAction)
{
int nvalue;

for (i = 1; i <= 4; i++)
{
if (currentAction == i)
nvalue = 1.00;
else
nvalue = 0.00;

switch(i)
{
case 1:
lr_user_data_point(“Register_1stBook”, nvalue); break;
case 2:
lr_user_data_point(“Register_Upload”, nvalue); break;
case 3:
lr_user_data_point(“RegisteredUser_Upload”, nvalue); break;
case 4:
lr_user_data_point(“PutOnSale”, nvalue); break;
}
}
}

USING THIS FUNCTION:
int mainRand = atoi(lr_eval_string(“{mainRandom}”));
i = 0;
if (mainRand <= lr_get_attrib_long(“attrib_Register_1stBook”))
{
if (Register_1stBook() == LR_PASS)
updateDataPoint(1);
}
else if (mainRand <= lr_get_attrib_long(“attrib_Register_Upload”) + lr_get_attrib_long(“attrib_Register_1stBook”))
{
if (Register_Upload() == LR_PASS)
updateDataPoint(2);
}
else if (mainRand <= lr_get_attrib_long(“attrib_RegisteredUser_Upload”) + lr_get_attrib_long(“attrib_Register_Upload”) + lr_get_attrib_long(“attrib_Register_1stBook”))
{
if (RegisteredUser_Upload() == LR_PASS)
updateDataPoint(3);
}
else
{
if (PutOnSale() == LR_PASS)
updateDataPoint(4);
}
return 0;

Tip of the day : Finding a software Testing Job

here are many people who would like to get software testing jobs, but they are unsure about how to approach it. This may seem like a dream j...