Shipped: Step Variables

This week we shipped something that I like to think of as a Swiss army knife for writing good tests. We call them Step Variables.

With front-end testing, you often want to use dynamic content. Perhaps you want to use real login credentials, or you want to test a number of different strings for your search functionality. Step variables are simple placeholders that display dynamic content in your steps, and persist throughout your test.

How do Step Variables work?

Like this:

When a tester does this test, {{ random.email }} and {{ random.password }} are replaced with a random email address and a random password.

Let’s look at a couple of examples.

1. Random Strings

Sometimes we want a tester to input a string and then check for the existence of that same string later. A good example is a sign up flow. We typically want the tester to sign up with a certain email address, and then check if that email address is displayed correctly later on.

This is an expanded version of the example above. Before step variables we would have had to either specify a static string to signup with and then test for, which would not work because each user email has to be unique, or we would have had to tell the tester to make up a string and remember it, which is error-prone. Step variables make it easy!

2. Users

When testing we often see customers using a single test login email and password. This is problematic because of how Rainforest works – we send several hundred testers to your site in parallel to get your tests done super quickly.

To avoid race conditions and other weirdness we recommend you add a custom step variable. This could be as simple as an array of email and password combinations, or you could create multiple step variables based on user permissions, eg. AdminUser, RegularUser, SuperUser.

This example will give each tester a unique set of credentials from the array of admin users.

Adding new step variables

Go to the Step Variables settings page to see your existing variables and add new ones.

We’ve already found several weird and wonderful uses for Step Variables, and we’re excited to see what you come up with!

Fred is the CEO and co-founder of Rainforest QA. Fred spends all his time driving the company to build a better, faster way to do QA while remaining a place that people love to work at. Since Rainforest’s early days at Y-Combinator in 2012, Fred has led the company through rapid growth, building not only a QA platform that leverages both crowdsourcing and machine learning to accelerate testing, but also a team spread across 16 countries on 5 continents.