What Are Conditions and Actions?
A Test Data Rule (GRule or G-Rule) can have one or many Conditions and Actions, forming a conditional If-Then Statement. A sample If-Then Statement is shown below:
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)
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.
If (Account.balance <= 1000)
An Action represents the THEN portion of a conditional statement for 1 Domain and 1 Attribute. A rule can have one or multiple Actions.
Then (Customer.acccountType == Bronze)
In This Article
- Types of Conditions and Configuration Options
- How to Add Value-Based Rule Conditions
- How to Add Variable-Based Rule Conditions
- Type of Actions and Configuration Options
- How to Add Value-Based Rule Actions
- How to Add Generator-Based Rule Actions
Types of Conditions and Configuration Options
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).
- Variable-Based - The condition references a variable (e.g. Domain Attribute).
The following options are available when adding a condition to a rule:
Option | Required | Description |
Domain | Yes | A Domain from the Project Version the Test Data Rule Suite belongs to. |
Attribute | Yes | 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 | 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 will automatically be checked when the entered Value is a String and may be altered when needed. |
Condition | Yes | Used to form conditional statements where one or more conditions must be met for the defined actions to occur.
|
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 Rule Conditions
- Select the Rule and click on Add Condition.
- Select the Domain, an Attribute, and a Qualifier.
- Enter a Value that will be used to evaluate the condition.
- Select a Condition (e.g., AND, OR, THEN).
- Optionally, a Group Name if brackets are to be used.
- Click Save to finish.
- The condition will appear as shown below. An additional condition has been added in the screenshot below:
How to Add Variable-Based Rule Conditions
- Select the Rule and click on Add Condition.
- Select the Domain, an Attribute, and a Qualifier.
- Double-click the Value field to reference a Variable (Domain and Attribute).
- The variable will be used to evaluate the condition to determine whether it has been met.
- Select a Domain and an Attribute.
- Select a Condition (e.g., AND, OR, THEN).
- Optionally, enter a Group Name if brackets are to be used.
- Click Save to finish.
- The Value Column will show the referenced Domain and Attribute.
Type of Actions and Configuration Options
An Action defines what will occur 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 chosen Attribute
The following options are available when adding a condition to a rule:
Option | Required | Description |
Domain | Yes | A Domain from the Project the Test Data Rule Suite belongs to. |
Attribute | Yes | 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 the 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 Rule Actions
- Select the Rule and click on New Action.
- Select the Domain and an Attribute.
- Select 'Constant' for the Value Type.
- Enter the Value. It will be assigned to the selected Attribute when one or more Conditions are met.
- Click Save to finish.
Note: The Is String option will be automatically checked when the entered value is a string and not checked for numeric values.
How to Add Generator-Based Rule Actions
- Select the Rule and click on New Action.
- Select the Domain and an Attribute.
- Select Generator as the Value Type.
- One or more Generators can be selected. Multiple Generators will be linked automatically.
- 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.
- Click on the field again and type the name to add another Generator.
- 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 the 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 the registration number.
- The generated data value for the customer's registration number when their account type is Bronze will appear as shown below: