Description

Test Data Rules are a key part of GenRocket's Self Service Test Data Portal. We organize all the Test Data Rule functionality into a part of the GenRocket platform we call "G-Rules".


When should you use Test Data Rules?

  • Any time you want to apply business logic to generated test data. 


How do you use Test Data Rules?

  1. Create a Test Data Rule Suite to organize the Test Data Rules into a group of rules
  2. Create different Test Data Rules within the Suite
  3. 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.


Overview Video

Please take a minute to view the following video showing how Test Data Rules work in GenRocket:


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 take place 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 which is used when no other Test Data Rule Conditions are met.


How do I use Test Data Rules?

In just a few steps, you can define a Test Data Rule.


Note: Test Data Rules may run with Test Data Cases, which allows business logic to be applied to a specific Test Data Case. 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.


For this example the Test Data Rule Suite has been named "SampleTestDataRules".


Note: For detailed steps on how to create a Test Data Rule Suite, click here


Step 3: Add Test Data Rules to the Suite

Each individual Test Data Rule defines one or more Conditions that must be met for the added Action(s) to take place during test data generation. In order to set up Conditions and Actions, you must first add one or more Test Data Rules to the suite.


For this example, 4 Test Data Rules and a Default Test Data Rule have been added. 


Note: For detailed steps on how to add a Test Data Rule to a suite, click here


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.



Note: For detailed steps on how to add a Condition to a Test Data Rule, click here


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:



Note: For detailed steps on how to add an Action to a Test Data Rule, click here


Step 6: Download the Scenario, Scenario Chain, or Scenario Chain Set

Next, you will need to download the Scenario, Scenario Chain, or Scenario Chain Set it will be run with in 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 7: Download the Test Data Rule Suite

To successfully run a Test Data Rule Suite and generate test data with the defined logic, you will also need to download the Test Data Rule Suite to your local computer. To do so, click on the Download (Cloud) icon within the Action column of the G-Rules Dashboard.


Step 8: 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 then 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:


Note: For detailed steps on how to download and run a Test Data Rule Suite, click here.


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, 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: