Variables Parameters and Scenarios

One of the most important aspect in any framework is how to declare or extract variables and how to pass them as parameters to different functions. Testerum allows you to do this in an easy manner.

Environments and Global Variables

In order to define a new Environment or a Global Variable you have to press the button from (img 1)
img 1
View & Edit Variables button

In the Variables popup (img 2) you can define your Environments and the variables assigned to them.

img 2
View & Edit Variables popup

Before reaching the production, a particular software version will be deployed on multiple environments like:

Environment Name Description
Local Developer's or Tester's computer
Development/Trunk Development server acting as a sandbox where testing may be performed by the developer
Integration CI build target, or for developer testing of side effects
Testing/Test/QC/Internal Acceptance The environment where QA Team performs their tests.
Staging/Stage/Model/Pre-production/External-Client Acceptance/Demo Mirror of production environment
Production/Live Serves end-users/clients

For each environment you will probably need to define a set of variables that will be used by you tests. For example: application URL, database URL, database password, etc. Testerum comes with two environments predefined:

How to use variables

A variable can be used with the following pattern: {{variable_name}} Example: Given you have declared the Global or Scenario Variables: URL, USER_NAME and PASSWORD then you can use them like in the following test (img 3)

img 3
How to use variables

Parametrization

In this chapter we will show you how to create Custom Steps with parameters.

Definitions:
    Custom Steps are the steps defined by you that reflects your business model.
    Basic Steps are the pre-built steps that are shipped with Testerum and are technology integrations.
First, let's consider a test where values are hardcoded in the step definitions (img 4).
img 4
Test with hardcoded parameters
Now let's parameterize the second step "When I fill in 'admin' as user name and 'test123' as password": For this we have to edit the step (img 5):
img 5
How to edit an parameterized step
And replace the hardcoded values 'admin' and 'test123' with parameters.
img 6
Parametrized Steps

To define a Parameterized Composed Step you have to use the following pattern: {{parameter_name}} After adding the parameters <<userName>> and <<password>>, these can be accessed from the sub-steps as we access any variable, by enclosing them inside double curly brackets {{userName}}, {{password}} (img 7)

img 7
Parametrized Steps

Now, the step definition should look like this: When I fill in <<userName>> as user name and <<password>> as password It has two parameters which are waiting for some values. (img 8)

img 8
Parametrized Steps

At runtime, the expressions {{userName}}, {{password}} will be evaluated and replace with the values passed to the parent step parameters.

img 9
Parametrized Steps

At this point, basically we are done with the parametrization of this step.
From now on, you can simply reuse it and add different input data.

img 10
Parametrized Steps

Notice: Parametrization merged with Scenarios will make your tests very robust.

Scenarios

Sometimes you want to execute the same test with different parameters. For this, in Testerum, a test can have multiple Scenarios To add a Scenario to your test, press the Add Scenario button.

img 11
Add Scenario button

When you add a new scenario you can:

img 12
Add Scenario Parameter Button

When you add a parameter you need define the Name, Type and Value (img 13):

img 13
Add Scenario Parameter

If you define a Test with multiple Scenarios, your Test Steps will be executed once for each Scenario. (img 14)

img 14
Test with multiple Scenarios

There is no need to lose time writing again ang again the same test case which contains different input data. Scenarios provides a cleaner then to copy-paste your Tests with different parameters. Follow this approach and you will reduce significantly the effort in writing and maintaining your automated tests. (img 15)

img 15
Scenarios

Text vs JSON Parameter Type

A Scenario Parameter Type can have two possible values: Text and JSON On how to use the Text Type see the above example. Choosing the Type as JSON gives you some extra flexibility and might be a very good option for complex cases where you have many parameters. (img 16)

img 16
Scenario Parameter of type JSON

Defining a parameter like in the (img 16) allows you to access the values in a more dynamic way:

Examples:
  1. {{person.firstName}} will return "Robert"
  2. {{person.address.city}} will return "Manchester"
  3. {{person.address}} will return  { "city": "Manchester", "street": "Buckland Hills", "postCode": "CT 6040", "houseNumber": "420" }
Using the technique from the example 3. you can pass complex parameters to your steps.