Thursday, February 13, 2014

Load test with Jmeter & Unique email

Some days ago i have been assigned to do a load testing. 
That page have a form, and I have to provide UNIQUE email address each time i submit the form.
So i started to look into the net and with the QA team how can i generate a unique ID and append to an email prefix to make the address unique. 
There are many ways to make it unique, but the best solution i have found is UUID (Universally unique identifier), If you want you can read more about it. 
There is tiny chance that it will be duplicate, actually frankly saying there is none. 

Here is the code for it: 
${__BeanShell(UUID.randomUUID().toString(),email_id)}@test.com
I used a "Response Assertion" which confirm us that we have gone to the nest page after the successful submission

BeanShell Sampler to print the result in console to see the generated and submitted email id's.


How the console shows the UUID:



Special thanks to one of my colleague Masud Parvez, who really help me lot building this script.

1 comment:

  1. It isn't very recommended to use Beanshell for severe load as Beanshell interpreter parsing code each time being called. JMeter provides __UUID function which does exactly the same without performance overhead. See How to Use JMeter Functions post series for extended information on above and much more.

    ReplyDelete