What Are Conditional Logic Generators?
Conditional or Business Logic Generators allow you to generate the exact conditioned test data required to run a given test and test a specific outcome. Depending on the generator, you can define one or many conditions that determine the possible generated output for each specified condition. The generated output is determined by which condition evaluates as 'true.'
Conditional Logic Generators can reference other attributes or linked generators to meet the needs of more complex scenarios. Additionally, the generated output for a met condition can be a constant value or a referenced attribute/generator. Some generators only support one condition, while others support multiple conditions.
Simple Example 1:
If (gender male)
generate male name
else
generate female name
Simple Example 2:
If (age >= 18)
generate 'adult'
else
generate 'minor'
Note: Many shared links on this page for generators use linked generators for the examples; however, you can also reference attributes in the parameters.
Conditional Logic Generators vs. G-Rules
Conditional Logic Generators can be assigned to an individual attribute to control or condition the output of a specific Domain Attribute. They can be assigned at the Domain (Template), Scenario, or G-Case level (depending on needs).
G-Rules can contain the same or similar logic defined for each generator below and generate conditioned test data that meets that logic. Conditions and actions belong to individual rules, which define the required logic that generated test data should adhere to.
A condition or action within a G-Rule can also utilize a Conditional Logic Generator. G-Rules are great for complex test data generation scenarios where the generated test data depends on multiple conditions or complex logic. You can also generate different variations and volumes of test data by creating G-Cases and adding G-Rules to them.
Calculation-Based Generators
These generators use an equation to calculate the desired output:
Generator | Description | Examples |
CalcGen | Calculates the equation using up to five variables. Variables can either be constant values or references to other attributes. Use this generator for simple or complex equations that result in a numerical value. | Compound Interest
|
Condition-Based Generators
These generators use one or more conditions or cases to generate conditioned output.
Generator | Description | Examples |
(recommended) | Evaluate equations using up to 5 variables. When true, it returns the value of parameter caseTrue; otherwise, it returns the value of the parameter caseFalse. This generator only supports one condition/equation. The variables caseTrue and caseFalse can be constants or referenced values (attribute, linked generator, etc.). For multiple equations, please use the EvalCaseActionGen. | 1. Check if a number is positive or negative 2. Check if a number is odd or even 3. Generate names based on gender |
EvalCaseActionGen (recommended) | Emulates multiple if-then-else statements by returning the first true value. It works similarly to EvalCaseGen but allows for multiple equations. | 1. Assign status based on age:
|
(recommended) | Emulates a Java switch statement. It returns the value of the matched case. You can define multiple cases (conditions), and the generator will generate the value of the matched case. This generator is useful for simulating decision-making or conditional logic during data generation. | 1. Generate names based on gender. 2. Generate access level based on user role. |
Emulates multiple if-then-else statements. Data is generated for the first true case. This generator can be used for more complex scenarios that involve multiple cases where only one will evaluate to true. | 1. Generate a mode of transportation based on the first true case.
2. Generate a status such as approved, rejected, or pending. | |
EvalGen | Evaluates simple to complex equations using up to 8 variables to return a true or false result. This generator can evaluate an equation to obtain a true or false result. It can also be linked with another generator, which uses the true/false result to generate test data. If the output should be a different constant value or a referenced generator/attribute, you can use the EvalCaseGen or EvalCaseActionGen. | Check if a number is even, odd, positive, negative, or zero. Equation Examples var1 > var2 (var1 * var2) * var3 (var1/var2)+var3 |
EvalCaseSentenceCSVGen | Emulates multiple if-then-else cases by returning the first true value and loads the Subject, Predicates, and Clause from a CSV file to make sentences. | See this page for a complete example: How do I use the EvalCaseSentenceCSVGen Generator? |
EdgeCaseGen | Generates edge case data that is useful for negative testing and edge cases. Note: Negative Testing is also possible with G-Cases. | Create a number between 1 and 1000 when true; otherwise, create a number between 5,000 and 10,000. Additional edge case examples:
|
Evaluate a Boolean referenced value and select one of two referenced values based on the True or False result:
This generator is great for more straightforward conditions with only two outcomes. | 1. Check if a user is above 18, generate Minor or Adult 2. Check if a name is greater than 10 characters, and generate 'Invalid' or 'Error' if greater than 10 3. Check salary to see if high or low-income 4. Check if the country is 'USA' and generate 'Domestic' or 'Foreign' (works the same for other countries) | |
LessThenEqualGen | Allows one or more <= conditions. This generator can only be used to check if a value is less than or equal to another. You can also use the EvalGen or EvalCaseGen for more complex equations, including comparisons. Use the EvalCaseActionGen for multiple equations. | Check if a number falls within an upper limit, such as if the price is less than or equal to a budget. |
Percentage-Based Generators
The generated output is based on a defined percentage for each value.
Generator | Description | Examples |
WeightGen | Defines a percentage between 1 and 100 to determine how often values generated from variable1 will be selected over values generated from variable2. Variables can be constant values or referenced generators/attributes. This generator only allows the percentages to be split between two variables. Please use the MultiWeightGen when more will be needed. | 1. Generate 'Pass' 70% of the time and 'Fail' 30% of the time. 2. Generate one referenced generator or attribute 60% of the time and another 40% of the time. |
MultiWeightGen | Allows multiple values to be weighted by percentage to determine how often each value is generated. You can enter a percentage value or reference a value for the percentage. This generator is more flexible than WeightGen above. Note: The MultiWeightGen works in the totality of all rows and does not consider parent/child relations. The MultiWeightChildGen distributes the values among children. | 1. Generate a mode of transportation based on percentages:
2. Generate a customer type:
3. Generate product categories:
Additional examples: |
MultiWeightChildGen | This generator allows the percentage distribution of data among the children of a Parent Domain. It works similarly to MultiWeightGen and allows multiple values to be weighted (percentage) to determine how often each value is generated among child records. | For a specified parent, out of 'n' children:
The 'n' number of children can change for each parent. The first parent may have 5 children, and the next parent may have 20 children. So, the distribution of different-colored bags among a parent's children will be based on the defined percentages. |
MultiWeightCSVGen | Loads the values and their weights (percentages) from a delimited file. It works like MulitWeightGen, but its values come from a CSV file. | Examples are the same as MultiWeightGen. The only difference is the percentages are pulled from a CSV file. |
MultiWeightSwitchCSVGen | Reads metadata from a CSV file to map multiple MultiWeightGen generators into memory. | Generate records for each state, where the date column should either contain a date or be blank. The percentage varies per state. |
MultiWeightRegexGen | Allows multiple regex values to be weighed to determine how often each value is generated. | The valueList contains (ab*, [0-9],%, ^,{3}$), and the percentList contains (50, 35, 15):
|