Description
Test Data Rules are a key part of GenRocket's Self Service Test Data Portal. They are used to ensure that generated test data meets specified business logic for testing purposes.
We organize all the Test Data Rule functionality into a part of the GenRocket platform we call "G-Rules" (also referred to as "GRules" in some articles).
When should you use Test Data Rules?
- Any time you want generated test data to adhere to specific business logic.
How do you use Test Data Rules?
- Create a Test Data Rule Suite to organize the Test Data Rules into a group of rules
- Create different Test Data Rules within the Suite
- Build out your different Test Data Rules with Conditions and Actions
Note: A Default Test Data Rule can also be added to a suite, which defines the default action when no conditions are met within the rule.
In This Article
- Overview Video
- GenRocket Methodology Phase
- Relevant User Role(s)
- Definitions
- How do I use Test Data Rules?
- Defining a Test Data Rule Example
- Additional Information
- Usage Examples
Overview Video
Please take a minute to view the following video showing how Test Data Rules work in GenRocket:
GenRocket Methodology Phase
- Design Phase
Relevant User Role(s)
- Test Data Engineer (TDE)
- Org Admin
Definitions
- Test Data Rule Suite - A group of Test Data Rules that can be applied when generating test data with a Scenario, Scenario Chain, or Scenario Chain Set. A given Project Version can have one or multiple Test Data Rule Suites.
- Test Data Rule - Defines the conditions to be met for a specified Domain and Attribute and the actions to be performed when those conditions are met. Test Data Rules form a conditional if-then statement.
- Condition - A condition that must be met for a specified action to take place during data generation. A Condition represents the IF portion of a conditional statement.
- Action - What will occur when the condition is met for the defined Domain and Attribute. An Action represents the THEN portion of a conditional statement.
- Test Data Default - A default rule used when no other Test Data Rule Conditions have been met.
How do I use Test Data Rules?
In just a few steps, you can define a Test Data Rule.
- Story
- Domains and Attributes
- Step 1 - Select the G-Rules Option
- Step 2 - Create a Test Data Rule Suite
- Step 3 - Add Test Data Rules to the Suite
- Step 4 - Add Conditions to each Test Data Rule
- Step 5 - Add Actions to each Test Data Rule
- Step 6 - Generate Test Data with Test Data Rules
- Completed Story
- Sample Output
Note: Test Data Rules may run with Test Data Cases, which allows the generated test data for a specific Test Data Case to follow defined business logic. To learn how to add a Test Data Rule Suite to a Test Data Case, click here.
Defining a Test Data Rule Example
Story
A QA Tester needs to generate account test data, but specific logic must be applied when the test data is generated. For this example, a reward level must be assigned based on the account balance. Four reward levels can be assigned depending on the balance total:
- Platinum
- Gold
- Silver
- Bronze
When none of the conditions are met, the reward level will need to be set to Basic. To achieve this testing goal, the tester will need to create a suite of Test Data Rules to define the business logic to assign the appropriate reward level to each account when test data is generated.
Test Data Rule 1
IF (Account.balance >= 7000 AND Account.balance <= 13000)
THEN
Account.rewardLevel == 'Platinum'
Test Data Rule 2
IF (Account.balance >= 3000 && Account.balance <= 6999)
THEN
Account.rewardLevel == 'Gold'
Test Data Rule 3
IF (Account.balance >= 1000 AND Account.balance <= 2999)
THEN
Account.rewardLevel == 'Silver'
Test Data Rule 4
IF (Account.balance >= 500 AND Account.balance < 1000)
THEN
Account.rewardLevel == 'Bronze'
Default Rule
Account.rewardLevel == 'Basic'
Domains and Attributes
An Account Domain has been created with the following 4 Attributes:
- id - Identifier for the Domain
- accountNumber - Individual's account number in the system.
- balance - Account balance for the data record.
- rewardLevel - Assigned reward level for the data record.
Let's follow the steps below to create our Test Data Rule Suite:
Step 1 - Select the G-Rules Option
Expand the Self Serve Menu Options drop-down menu within the Project Versions Pane and select G-Rules. Test Data Rules are specific to a Project Version within a given Project.
Step 2 - Create a Test Data Rule Suite
Next, a Test Data Rule Suite will need to be created. A suite contains the Test Data Rules that will apply business logic during test data generation. A Test Data Rule Suite can have:
- One or many Test Data Rules with their own Conditions and Actions
- No conditions at all and one or more Actions
- A Default Test Data Rule that is applied when no conditions are met
A user can set up their own Test Data Rule Suites consisting of one or more Test Data Rules, which can be used to apply logic when generating test data.
The Test Data Rule Suite has been named "SampleTestDataRules" for this example.
Step 3 - Add Test Data Rules to the Suite
Each Test Data Rule defines one or more Conditions that must be met for the added Action(s) to take place during test data generation. To set up Conditions and Actions, you must first add one or more Test Data Rules to the suite.
For this example, four Test Data Rules and a Default Test Data Rule have been added.
Step 4 - Add Conditions to each Test Data Rule
A Condition is the IF portion of the conditional statement. A Test Data Rule can have one or more Conditions. When multiple Conditions are used, they must be compounded with an AND or OR. Conditions are defined for 1 Domain and 1 Attribute. Here is a sample configuration for a constant value:
In the example below, rule1 defines the logic for assigning the Platinum reward level and has two compounded Conditions.
Step 5 - Add Actions to each Test Data Rule
An Action is the THEN portion of a conditional statement. An Action can only apply to 1 Domain and 1 Attribute. The Action defines what will happen when a Condition is met. If a Condition is not met, the Action will not be taken, and the next Condition is evaluated.
Actions can have a defined constant value or use one or more Generators to generate the required value during test data generation. Here is a sample configuration for a constant value:
The Action defines what will happen when the defined Condition is met for rule1:
Step 6 - Generate Test Data with Test Data Rules
Test data can be generated in one of two ways with G-Rule Suites:
- Download the G-Rule Suite and run it with a Scenario, Scenario Chain, or Scenario Chain Set.
- Add the Test Data Rule Suite to a Test Data Case (G-Case). It will be applied automatically when the G-Case is run with a Scenario, Scenario Chain, or Scenario Chain Set.
This article will show how to generate Test Data with G-Rules and a Scenario. To learn how to add a G-Rule Suite to a G-Case, click here.
Step 6a - Download the Scenario, Scenario Chain, or Scenario Chain Set
Next, you will need to download the Scenario, Scenario Chain, or Scenario Chain Set to be run within GenRocket Runtime. This can be done by clicking on the Download (Cloud) Icon with the Scenarios, Scenario Chains, or Scenario Chain Sets Pane of the Project Dashboard.
Step 6b - Download the Test Data Rule Suite
To successfully run a Test Data Rule Suite and generate test data with the defined logic, users must also download the Test Data Rule Suite to their local computer. To do so, click on the Download (Cloud) icon within the Action column of the G-Rules Dashboard.
Step 6c -Copy the Command Line and Run the Command
The command to run the Test Data Rule Suite can be found at the bottom of the G-Rules Dashboard for a selected suite. This command can be copied and pasted into a Command or Terminal Window.
When you paste the command, all you have to do is enter the file name for the Scenario, Scenario Chain, or Scenario Chain Set and then run the command.
Paste or enter the command line into a Command or Terminal window with the name of the downloaded Scenario, Scenario Chain, or Scenario Chain Set:
Completed Story
In just a few minutes, we are able to define a suite of Test Data Rules to assign a specific reward level to an account based on its balance. And best of all, this Test Data Rule Suite can be used to modify any Scenario, Scenario Chain, or Scenario Chain Set or added to and run with any Test Data Case.
Sample Output
Additional Information
For information about Test Data Rule Suites and Rules, please see the following pages:
Topic | Description |
Learn more about accessing G-Rule Suites. | |
Learn more about creating G-Rule Suites. | |
Learn more about adding G-Rules to a suite. | |
Learn more about using a Default G-Rule. | |
Learn more about configuring G-Rule Conditions and Actions. | |
Learn more about copying G-Rule Suites. | |
Learn more about changing the name of a G-Rule Suite. | |
Learn more about viewing G-Rule reports. | |
Learn more about locking and unlocking G-Rule Suites. | |
Learn more about removing a G-Rule Suite from a Project Version. | |
How to generate test data with G-Rules and a Scenario | Learn more about downloading and running a G-Rule Suite with a Scenario. |
Usage Examples
Topic | Description |
Test Data Rules Example: Assign Reward Level by Account Balance | See a step-by-step example of assigning reward levels to customers based on the account balance amount. |