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 Actions and Conditions


Overview Video

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


Test Data Rule Example

Let's say user data is being generated and only users falling with a specified age range can be allowed to participate in a program. If this test data is generated without logic, then users with the wrong age may be allowed to participate.


Business logic contains the necessary conditions and actions for ensuring only users with the appropriate ages are able to participate. The following would be a simple example of two Test Data Rules and their Conditions/Actions:


Test Data Rule 1

IF (User.type == child && User.age <= 17)
THEN
User.allowedToParticipate == false

(or)


Test Data Rule 2

IF (User.type == adult && User.age >= 18)
THEN
User.allowedToParticipate == true


Test Data Rules can be used to set up and test business logic for data generated by Domains within a Project or Project Version. Each Test Data Rule contains one or more Conditions and Actions, which are applied during data generation.


Definitions

  • Test Data Rule Suite - A group of Test Data Rules that can be downloaded and ran with a selected Scenario or Scenario Chain. 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. A Test Data Rule Suite can contain one or multiple Test Data Rules.

  • Condition - A case that must be met for a specified action to take place during data generation.

  • Action - What will take place when the condition is met for the defined Domain and Attribute.

  • Test Data Default - A default rule which is used when no other Test Data Rule Conditions are met.


How Do Test Data Rule Suites Work?

Test Data Rule Suites need to have the following to meet minimum configuration requirements: 

  • 1 Test Data Rule
  • 1 If Condition
  • 1 Then Action

 

Additionally, you may define a Default Test Rule, which defines the default action when no defined conditions are met within the rule.


Once a Test Data Rule Suite has been set up, it can downloaded and ran individually with any Scenario, Scenario Chain, or Scenario Chain Set within a given Project. The defined Receivers will be used to generate the output data. 


Test Data Rules may ran with Test Data Cases, which allows business logic to be applied to a specific Test Data Case being ran on a user's local machine. To learn how to add a Test Data Rule Suite to a Test Data Case, click here.


How do I use Test Data Rules?

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

  1. Select the Test Data Rule Menu Option
  2. Create a Test Data Rule Suite
  3. Add 1 or More Test Data Rules to the Suite
  4. Add 1 or More Conditions to each Test Data Rule
  5. Add 1 or More Actions to each Test Data Rule Condition
  6. Download and Run the Test Data Rule Suite


Defining a Test Data Rule Example

Story

A QA Tester needs to generate user test data, but specific logic must be applied when the test data is generated. For this example, the user can only participate if they are 18 and older. In order to apply this logic, the tester will need to create Test Data Rules that define it. 


Logic

The allowedtoVoteParticipate is assigned based on the Age Attribute.

  • If 17 or below, then not allowed to participate
  • If 18 or above, then allowed to participate

Domains and Attributes

A User Domain has been created with the following 5 Attributes:

  • id - Identifier for the Domain.
  • firstName - First name of the user.
  • lastName - Last name of the user.
  • age - Age of the user.
  • allowedtoParticipate - True or False


Let's follow the steps to create our Test Data Rule.


Step 1: Select the G-Rules Option

Expand the Manage menu in the Project Versions pane and select G-Rules. Test Data Rules are specific to a Project Version within a 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 be applied when test data is generated. For this example the Test Data Rule Suite has been named "SampleTestDataRules".


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.


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


Step 3: Add Test Data Rules to the Suite

For this example, 2 Test Data Rules will need to be created. The first rule (rule1) defines the logic for individuals who are 17 and under. The second rule (rule2) defines the logic for individuals who are 18 and over.


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


Step 4: Add Conditions to each Test Data Rule

When defining a Condition, you will need to select the Domain and Attribute it applies to. rule1 defines the logic for when the individual is 17 or younger. 



rule2 defines the logic for when the individual is 18 or over.


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

When defining an Action, you will need to select the Attribute it applies to. The Action defines what will happen when the defined Condition is met for rule1:



The Action defines what will happen when the defined Condition is met for rule2:



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


Step 6: Download and Run the Test Data Rule Suite with a Scenario

To successfully run a Scenario with a Test Data Rule Suite, both the Scenario and the Test Data Rule Suite will need to be downloaded to the user's local machine.


To download a Test Data Rule Suite, click on the Download (Cloud) icon within the Action column.


The command to run the Test Data Rule Suite with the downloaded Scenario can be found at the bottom of the Test Data Rules Dashboard.


Enter the command into a Command or Terminal window with the name of the downloaded Scenario:


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


Additional Information

For information about Test Data Rule Suites and Rules, please see the following pages: