Thursday, May 2, 2013

How to generate unique file names?

While running load test it is quite possible that two or more users will create a file so to make it unique, we need some parameters that are able to differentiate these created files and this can be done by using Vuser ID, Iteration Number, Date and Time stamp.

Again, just a three step process ;)
Click here to know more

Step 1: Go to tab Vuser > Parameter list and create three parameters:
  1.  First one: Name unique_vuser; Type Vuser ID.
  2. Second one: Name unique_ itr; Type Iteration.
  3. Third one: Name unique_ dt; Type Date/Time.
Note: Use the Date/Time format - "%Y%m%d_%H%M%S.000".
This format means Years Months Days Hours Minutes Seconds Milliseconds. Using this we will get string like:  
20130421_100523.786

Step 2: Write the below code in the script:
lr_output_message(lr_eval_string("{unique_vuser} _{unique_itr}_{unique_dt}"));
This will generate unique string for the current LR Vuser and you can save the current file as “5_4_20130421_100523.786.pdf”.This implies 5th Vuser 4th iteration and 21st April 2013, ten past five twenty three seconds and 786 milliseconds.


Wow, you did it in two steps only. Congrats!!! Nice move ;)

No comments:

Post a Comment