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
Slack

Test Your Website Performance NOW! |

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

How to Generate Parameterized Email Addresses for Your Test Runs with BlazeData

In this blog post I would like to show you a very fundamental functionality we have in BlazeData:  the ability to reference parameters inside other parameters, to create email addresses. In other words, this means you can use the value of one parameter, to generate another parameter: the email address. This will help you quickly generate valid emails for your software tests.

 

Let's see some examples of how it works. 

Use Case 1: Generating an Email Address from Parameters

Let’s say I would like to use an email address in my test and I want BlazeData to generate one for me.

 

We will divide the email value into several standalone values - the first name, the last name and the domain name. This is the best way to keep my data model clean and easy to read.

 

So I have defined these three params:

 

Firstname - randFromSeedlist("firstnames")

Lastname - randFromSeedlist("lastnames")

Domain - "acme.com"

 

As you can see, I used the randFromSeedlist function, which returns a random value from a stored list.

 

Pro tip #1: In BlazeData, we provide several seedlists out of the box.

 

Now we can take these parameters and put them together into an email address.

 

Email - $Firstname + "." + $Lastname + "@" + $Domain 

 

Prop tip #2:: You can always hit ‘preview’ to see what your value will look like before generating it.

 

Pro tip #3: You can add the "." separator into a standalone parameter if you know you will be changing it. Then it would look like this:

 

Separator - “.”

 

Email - $Firstname + $Separator + $Lastname + "@" + $Domain

Use Case 2: Generating an Email Address Without Spaces

Our names seedlists might return values that consist of two names separated by a space. This will create an invalid email. In order to fix this case, we will use a javascript built-in function to replace potential spaces with dots (.). This function will increase the robustness of our test and decrease the number of false negative test runs.

 

With the replacement function our parameters will look like this:

 

Firstname - randFromSeedlist("firstnames").replace(" ", ".")

Lastname - randFromSeedlist("lastnames").replace(" ", ".")

 

Use Case 3: Regular Expressions 

The replacement function from before can also work with regular expressions, which are more powerful and can perform multiple actions at once. We can leverage this capability: instead of replacing one space occurrence in each parameter, we can replace all occurrences in the email address at once. It will look like this:

 

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

 

This final statement provides quite a robust way to generate nice and valid email addresses.

 

That’s it! This is everything I want to show you today. Now you know how to parameterize your tests and how to link parameters inside another parameter which brings you much better flexibility during creating your tests.

 

Additional information about BlazeData, its functions and seedlists 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!