Description
Once a Test Data Rule has been added to the suite, the next step will be to add one or more Conditions and Actions to form a conditional statement. Test Data Rules may have multiple Conditions and Actions.
What is a Conditional Statement?
- A Conditional Statement is an If-Then Statement. For Example:
IF (Account.balance <= 1000)
THEN (Customer.acccountType == Bronze) - IF Statements can be compounded with an AND or OR as well. For example:
IF (Account.type == Bronze) OR (Account.type == Gold )
THEN (Account.rewards == false)
What is a Condition?
- A Condition represents the IF portion of a conditional statement for 1 Domain and 1 Attribute. Conditions can also be combined using an AND or OR. Here is an example of a Condition:
IF (Account.balance <= 1000)
What is an Action?
- An Action represents the THEN portion of a conditional statement for 1 Domain and 1 Attribute. A rule can have one or multiple Actions. Here is an example of an Action:
THEN (Customer.accountType == Bronze)
How do you use Conditions and Actions?
Conditions and Actions form a conditional if-then statement that defines the business logic to be applied when test data is generated for specified Domains and Attributes. Each Test Data Rule can have one or many Conditions and Actions.
- Select (or add) a Test Data Rule within a Test Data Suite
- Add a one or more Conditions to the Test Data Rule
- Add one or more Actions for each Condition
Note: For more information about accessing and viewing Test Data Rule Suites, please see: How to Access and View Test Data Rules for a Project.
In This Article
The following topics are covered in this article:
- How to Add and Configure Conditions for Test Data Rules
- How to Add and Configure Actions for Test Data Rules
- How to Edit Conditions and Actions for Test Data Rules
- How to Delete Conditions and Actions from Test Data Rules
How to Add and Configure Conditions for Test Data Rules
A Condition defines what criteria must be met for a corresponding action to take place. A Condition can be:
- Value-Based - The Condition is based on a constant value (e.g. true, false, yes, no, etc.).
- Variable-Based - The Condition references a variable (e.g. Domain Attribute).
Condition Configuration Options
When a Condition is defined for a Test Data Rule, it determines what action will be taken based on the configuration options shown below:
Each option is described in further detail below:
Option | Required | Description |
Domain | Yes | This is a Domain from the Project Version the Test Data Rule Suite belongs to. |
Attribute | Yes | This is an Attribute from the Domain selected for the Condition. |
Qualifier | Yes | The qualifier determines how certain or absolute the Condition is in relevance to the Value. The following Qualifiers are available for a Condition.
|
Value | Yes | This is the Value that corresponds with the Qualifier. (Example - if Account.balance < 1000). A value may be entered manually or double click to select a variable to reference. |
Is String | No | This box should be checked if the Condition is a String. It will be automatically checked if the entered value is a string. |
Condition | Yes | Used to form conditional statements where one or more conditions must be met for the defined actions to take place.
|
Group | No | Enter a name to set up brackets for the condition. Example: if (type=child && age<=10) or (type=child && age <=18), then action. For example, the first set of brackets could be labeled as Group A and the second as Group B. A Group Name is optional when setting up a Test Data Rule Condition. |
How to Add Value-Based Conditions to a Test Data Rule
Complete the following steps to add a Condition to a Test Data Rule:
- Click on Add Condition within the If Condition section of the Test Data Rule configuration.
- Next, select the Domain the condition will apply to. For this example, the Account Domain will be used.
- Select the Attribute the condition will apply to. For this example, the Balance Attribute will be used.
- Select a Qualifier. For this example, < will be chosen.
- Next, enter a Value that will be used to evaluate the condition to determine if it has been met or not. For example, IF the Account.balance is < 1000, then Action.
- Click on the field once to enter a number or text value.
- Select a Condition for the Test Data Rule. For this example, THEN is chosen.
- Enter a Group Name (Optional) for the condition if brackets are to be used.
- Click Save to finish.
- The new Condition will appear in the IF Conditions Table as shown below:
- The Pseudo Code Panel will also show a preview of the Test Data Rule Condition.
Note: The order of Conditions can be changed by performing a Click+Drag action. Drag a Condition up or down to change the order.
How to Add Variable-Based Conditions to a Test Data Rule
Complete the following steps to add a Condition to a Test Data Rule:
- Click on Add Condition within the If Condition section of the Test Data Rule configuration.
- Next, select the Domain the condition will apply to. For this example, the User Domain will be used.
- Select the Attribute the condition will apply to. For this example, the qualifier Attribute will be used.
- Select a Qualifier. For this example, == will be chosen.
- Next, double click on the Value field to reference to a Variable (Domain and Attribute). The variable will be used to evaluate the condition to determine if it has been met or not.
- Use the Filter option when many Domains are present.
- Click on a Domain to select it. The Domain's Attributes will appear to the right
- Next, click on a Plus (+) to select an Attribute.
- The variable will appear similar to what is shown below:
- Select a Condition for the Test Data Rule. For this example, THEN is chosen.
- Enter a Group Name (Optional) for the condition if brackets are to be used.
- Click Save to finish.
- The new Condition will appear in the IF Conditions Table as shown below.
- The Value Column will show the referenced Domain and Attribute.
- The Pseudo Code Panel will also show a preview of the Test Data Rule Condition.
Note: The order of Conditions can be changed by performing a Click+Drag action. Drag a Condition up or down to change the order.
How to Add and Configure Actions for Test Data Rules
An Action defines what will take place when one or more Conditions for the rule are met. An Action can be set up to do one of the following:
- Value-Based - Assign a specific value to the selected Attribute
- Generator-Based - Use a Generator to assign the value to the selected Attribute
Action Configuration Options
When an Action is defined for a Test Data Rule, it determines what will happen with the generated test data for a selected Domain and Attribute based on the configuration options shown below:
Each option is described in further detail below:
Option | Required | Description |
Domain | Yes | This is a Domain from the Project the Test Data Rule Suite belongs to. |
Attribute | Yes | This is an Attribute from the Domain selected for the Action. |
Value Type | Yes | This is the value type that will be used to assign the value to the attribute:
|
Value | Yes | This is the Value that will be assigned when a Condition is met. It is required when Constant is chosen for the Value Type. For example: If (Account.balance < 1000), Then (Account.type == Bronze). "Bronze" is the assigned Value in this example. |
Select Generator | Yes | The selected Generator(s) will be used to assign a value to the selected Domain Attribute when a Condition is met. It is required when Generator is chosen for the Value Type. For example: If (User.age >= 18), Then User.voterRegistrationNumber will have a value assigned from RandomGen Generator. This generator will assign a random number as the user's voter registration number. |
Is String | No | This box will automatically be checked when the entered Value is a String and may be altered when needed. |
How to Add Value-Based Actions to a Test Data Rule
To add an Action using a Constant Value to a Test Data Rule, complete the following steps:
- Click on New Action located within the Then Action section of the Test Data Rule configuration.
- Next, select a Domain and Attribute for the Action.
- In this example, the Account Domain and rewardLevel Attribute have been chosen.
- Select Constant for the Value Type.
- Enter the Value that will be assigned to the selected Attribute when one or more Conditions are met.
- In this example, the value will be Bronze.
Note: The Is String option will be automatically checked when the entered value is a string and not checked for numeric values. - Click Save to finish.
- The new Action will appear as shown below:
- It will appear similar to what is shown below in the Pseudo Code:
Note: The order of Actions can be changed by performing a Click+Drag action. Drag an Action up or down to change the order.
How to Add Generator-Based Actions to a Test Data Rule
To add an Action with an individual or linked Generators to a Test Data Rule, complete the following steps:
- Click on New Action located within the Then Action section of the Test Data Rule configuration.
- Next, select a Domain and Attribute for the Action.
- In this example, the Customer Domain and the registrationNumber Attribute have been chosen.
- Select Generator as the Value Type.
- You can select one or multiple Generators when adding an Action to a rule. If multiple Generator are selected, they will be linked automatically.
- For this example, three Generators will be added and linked to create a unique registration number when the customer's account type is Bronze (B#######).
- Click on the Select Generator field and enter part or all of the Generator name. You may also select the Generator from the provided drop-down menu.
- In this example, three Generators will be added and linked to create the customer's registration number: ConstantGen, RandomGen, and ConcatGen Generator.
- To add multiple Generators, click on the field again and begin typing the name of another Generator to select it.
- Click Save to finish.
- You will be redirected to the Generator Management Dashboard to make configuration changes for the selected Generator.
- Generators can be added, removed, linked and configured for the Action. Once all changes have been made, click the Save button.
- Here are the configurations for the three Generators in this example:
- ConstantGen Generator - Creates a constant value of B to place in front of registration number.
- RandomGen Generator - Creates a random number between 100000 and 999999.
- ConcatGen Generator - This Generator references the values generated by the ConstantGen and RandomGen Generators and combines them into one data value for the Action.
- ConstantGen Generator - Creates a constant value of B to place in front of registration number.
- The generated data value for the customer's registration number when their account type is Bronze will appear as shown below:
- Click on the breadcrumb bar to return to the G-Rule Dashboard and view the Action configuration.
- The new Action will appear as shown below:
- It will appear similar to what is shown below in the Pseudo Code:
Note: The order of Actions can be changed by performing a Click+Drag action. Drag an Action up or down to change the order.
How to Edit Conditions and Actions for Test Data Rules
A Condition or Action may be modified the same way. When editing the information for a Condition or an Action, you will be able to change any of the configuration options.
Note: The images below will show how to edit an Action with a constant value.
To edit a Condition or Action, complete the following steps:
- Click on the Edit (Pencil) Icon within the Action Column.
- Make any needed changes by clicking on the input fields or selecting options from the drop-down menus.
- In this example, the Value has been changed to Diamond.
- Click Save once finished to save your changes.
- Changes will be displayed within the appropriate section (Conditions or Actions) of the Test Data Rule configuration.
How to Delete Conditions and Actions from Test Data Rules
A Condition or Action may be deleted from a Test Data Rule in the same way.
Note: The images below will show how to delete an Action.
To delete a Condition or Action from a selected Test Data Rule, complete the following steps:
- Click on the Delete (Trash Can) Icon within the Action Column.
- Click Yes within the confirmation window to delete the Condition or Action.
Note: Click No to close the window without deleting the Condition or Action.