How to Switch Quickly Between Data Variants
Data Variants help you create instances of a Test Data Entity that you can easily switch in a test. Variants are available for all test types and will later become available for data-driven virtual services as well.
Usage
Variants help you create instances of a Test Data Entity that you can quickly switch between. Think of situations where you want to re-run the same test structurally, but with different test data: For example, you want to run the same registration test with user addresses for either US users, EU users, or APC users, so you can focus on testing specific address validation features.
To run such test variants, you could create multiple Data Entities with a parallel data structure. The Data Entities would need to have the same column names but could contain different values, and you would load a different Entity for each test run. This will work, the only disadvantage is, you would have to keep track of which Data Entities belong to which test or virtual service, among all the shared Data Entities.
Data Variants are an alternative that makes swapping between Data Entities quick and easy. When you load a Data Entity with Data Variants, it comes with a menu that lets you select from among its variants. Each Data Variant has the same column structure but can contain different (overridden) values. The Variants are saved and loaded together with their Data Entity.
The Default Variant
Data Variants are derived from one base variant called "default". You cannot add, delete, or rename parameters in variants because they are the same across all variants. If you add, delete, rename, modify a parameter in the default variant, this change propagates to all variants.
Example:
You have a Data Entity called "Users" that contains two Data Parameters:
-
Users:
-
age: randInt(20,80)
-
region: “US”
-
You create a variant of "Users" and name it "Teenagers". In it , you override the age value to randInt(15,19). Now you have:
-
Users (Default)
-
age: randInt(20,80)
-
region: “US”
-
-
Users (Teenagers)
-
age: randInt(15,19)
-
region: “US”
-
Later, in the default variant, you change the default region to "EU", which results in the following state:
-
Users (Default)
-
age: randInt(20,80)
-
region: “EU”
-
-
Users (Teenagers)
-
age: randInt(15,19)
-
region: "EU"
-
How to Create Data Variants
Data Variants are available in the following test types:
-
Functional and Performance Tests that have a Data Entity with Data Parameters associated
-
virtual services that have a Service Data Entity with Data Parameters associated
Follow these steps:
-
Open the Test or virtual service.
-
Open the Test Data pane or Service Data pane, respectively.
-
Click the Data Entity's ellipsis menu and select Manage Data Variants.
The Manage Data Variants of Data Entity “Name” window opens and shows the default variant. -
Click Add Data Variant.
A new variant is added to the list. -
Give each Variant a distinctive name so that team members know which one to select.
-
Click Save.
Your variants now appear in a menu below the Data Entity name. -
Select a data variant from the menu.
-
Edit the values in each data variant as needed.
Finally, select a data variant and run the test.
How to Edit Data Variants
When you edit data variants, the default values from the Entity are overridden and the new values stored in the variant.
Follow these steps:
-
Open the Test or virtual service.
-
Open the Test Data pane or Service Data pane, respectively.
-
Identify the Entity and select a data variant from its menu.
-
Edit the values in each data variant as needed.
-
To reset a value back to the default, click Reset Variant Override.
-
To add a column, switch to the default variant first.
-
Troubleshooting
-
If the Manage Variants menu item of a Data Entity is grayed out, add Data Parameters first.
-
If you try to add a new Data Parameter and get the error message "Modify property on non default dataset is not allowed", switch to the default Data Variant first.