In This Article
- Overview Video
- GenRocket Methodology Phase
- Relevant User Role(s)
- How do I use Test Data Rules?
- Defining a Test Data Rule Example
- Additional Information
- Usage Examples
GenRocket Methodology Phase
- Design Phase
Relevant User Role(s)
- Test Data Engineer (TDE)
- Org Admin
- 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?
- 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
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:
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'
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:
For information about Test Data Rule Suites and Rules, please see the following pages:
|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.|
|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.|