Petr is an R&D Manager with more than 20 years experience in leading software development teams.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
May 16 2021

How to Generate A Unique Email Address for Your Test Run with BlazeData

In my previous blog I described how to generate an email based on random values stored in BlazeData predefined lists. These are the parameters we have in our test data:


Firstname - randFromSeedlist("firstnames")

Lastname - randFromSeedlist("lastnames")

Domain - ""

Email - ($Firstname + "."+ $Lastname + "@" + $Domain).replace(/ /g, ".")


This example works fine. But, if you run your test with multiple iterations, there is still a certain probability of having generated the same email value more than once. In this blog I would like to show you how to assure your email address will always be unique. 


Generating a Unique Email Address for Testing


To generate a unique email address, use the function valueFromSeedlist instead of randFromSeedlist.


Function valueFromSeedlist returns a very concrete value from our predefined list from a specified position.


In order to use this function, we need to specify which position we would like to get the value from. To achieve this, we will introduce a new parameter called index.


Index - sequenceGenerator()


The function sequenceGenerator creates an index that will be increased with every test iteration. This will assure we will have different values for each iteration .


Now we will use this index in our email parameters, like this:


Firstname - valueFromSeedlist("firstnames", $Index)

Lastname - valueFromSeedlist("lastnames", $Index)

Domain - ""


The email structure remains the same as it was before:


Email - ($Firstname + "."+ $Lastname + "@" + $Domain).replace(/ /g, ".")


Advanced Use Case


Obviously our seedlists are not unlimited. There are about 1000 values in the firstnames and lastnames seedlists. So if you will be running a large number of iterations, our values would begin to repeat themselves (once you reach the end of the seedlist we will start again from the beginning).


In order to really assure your emails will be unique we can add a number to the name, so even though the name will be the same, the number will be unique. For this case, we can use our Index parameter from before and use it as part of our email value. Our email parameter will change to this:


Email - ($Firstname + "."+ $Lastname + "." + $Index + "@" + $Domain).replace(/ /g, ".")


Additional information about BlazeData, its functions and seed lists can be found in How To Use Test Data and Test Data Functions and Seedlists.


To get started with BlazeMeter, sign up for free here.


arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!