When test data is generated through the GenRocket web platform, it is based on each Domain's Attributes and their configured Generators. Sometimes logic is necessary to achieve the desired output for certain conditions.
For example, let's say user data is being generated and only users falling with a specified age range can be allowed to participate. 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 Rules can be used to apply business logic to 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.
- Test Data Rule Group - A group of Test Data Rules that can be downloaded and ran with a selected Scenario or Scenario Chain.
- 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.
- 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 Rules Work?
Test Data Rules contain business logic for defined Domains and Attributes within a selected Project or Project Version.
This logic ensures the appropriate Actions are taken when certain Conditions are met. These Actions are used to obtain the right outcome when generating test data.
A user can set up their own Test Data Rule Groups consisting of one or more Test Data Rules, which contain the logic necessary to correctly generate required test data.
The following apply to any added Test Data Rule Group:
- A Project (or Project Version) can have one or multiple Test Data Rule Groups.
- A Test Data Rule Group may have one or multiple Test Data Rules.
- A Test Data Rule may have one or multiple Conditions and Actions.
In the visual example below, each Test Data Rule has two Conditions and one Action. Both Conditions must be met for the rule before the defined Action can be taken for the record.
Test Data Rule Groups need to have the following to meet minimum configuration requirements:
- 1 Test Data Rule
- 1 If Condition
- 1 Then Action
Once a Test Data Rule Group has been set up, it can downloaded and ran with any Scenario or Scenario Chain within the Project. The defined Receivers will be used to generate the output data.
The following example shows a Test Data Rule Group that has been set up for a Project with 1 Domain: User.
This Domain has the following 5 Attributes:
- id - Identifier for the Domain.
- name - Full name of the user.
- age - Age of the user.
- type - Type of user (Child, Teenager, Young Adult, or Adult).
- allowedtoVote - True or False
With this example, there are two Attributes that rely on the Age Attribute to generate the appropriate data:
- The Type Attribute (Child, Teenager, Young Adult, and Adult) should be assigned based on the Age Attribute. For example, if the age is 11, then the user should be a child. However, if the age is 25, then they should be a young adult.
- The allowedtoVote Attribute is assigned based on the Age Attribute as well. For example, if the age is 16 then allowedtoVote should be False. However, if the age is 30, then allowedtoVote should be True.
When no business logic exists for the generated data, a user may be a teenager who is 25 and allowed to vote or an adult may be 18 and not allowed to vote.
Test Data Rules will need to be defined to ensure the right user type is assigned based on age and that only the appropriate ages are given the ability to vote.
Below is a screenshot example of the entire Test Data Rule Group. Each rule covers a specific set of conditions based on the user's Type and Age.
To see a step-by-step instruction for the example above, please see: Test Data Rules Example: Voting.
To learn more about setting up and configuring Test Data Rule Groups for a Project, please see: Configuring and Using Test Data Rules.