What Are Linked Generators?
Linked Generators provide the ability to generate complex conditioned test data without having to access another Attribute's generated value.
This is a very powerful GenRocket feature because linked Generators can directly reference each other within an Attribute as opposed to indirectly accessing another Domain's Attribute to get its Generated value. Thus, linking Generators to each other within an Attribute provides the ability to generate complex conditioned test data without having to access another Attribute's generated value. This also means that Attributes may reference other Attributes that generate complex test data via linked Generators, thus yielding even more complex, conditioned test data.
In This Article
- Video Tutorial
- How Linked Generators Work
- Linked Generator Types
- Linked Generator Design Patterns
- Example - Generate a Person's Full Name
- Additional Information
Video Tutorial
The following video tutorial can be used to learn more about Linked Generators:
Note: Click here to see step-by-step instructions on how to link generators for generating complex test data.
How Linked Generators Work
- Sequencing
- Linked Generators generate their data in a left to right sequence. This means that within a set of linked Generators, the leftmost Generator is generated first, the second to the leftmost Generator is generated second, the third leftmost Generator is generated third, and so on.
- Linked Generator Referencing
- Linked Generators can only reference sibling linked Generators that are positioned to the left of their position within the set of linked Generators. Referencing Generators to their right will yield null values because Generators linked to their right have not yet generated their data.
- Domain Attribute Referencing
- Within its given Domain, linked Generators may reference any of its left sibling Attributes to attain a generated value.
- Scenario Domain Attribute Referencing
- Within its given Scenario Domain, linked Generators may reference any of its left sibling Attributes to attain a generated value.
- Within its given Scenario, linked Generators may reference any of its sibling Scenario Domain's Attributes to attain a generated value.
- Within its given Scenario, linked Generators may reference its Parent Scenario Domain's Attributes to attain a generated value.
- Returning a Result
- Within the set of linked Generators, the right most Generator contains the generated value that is returned for the given Attribute.
Linked Generator Types
When GenRocket Generators are linked together, each Generator falls within one of three linked generator types:
- Eval-Linked Generator - Its generated value will be referenced and evaluated by one or more Mid-Linked and or a Final-Linked Generator.
- Mid-Linked Generator - References one or more Eval-Linked Generators to generate a mid-linked result and may be evaluated by one or more Mid-Linked or a Final-Linked Generator.
- Final-Linked Generator - References one or more Eval-Linked or Mid-Linked Generators to generate a final result.
Linked Generator Design Patterns
There are specific GenRocket Generators that may be used as Final-Linked Generators; each of these final-linked Generators presents its own design pattern to enable complex test data generation.
- Linked CaseActionGen Design Pattern
- Linked ConcatGen Design Pattern
- Linked MultiWeightGen Design Pattern
- Linked SwitchGen Design Pattern
Example - Generate a Person's Full Name
Let's say we want to generate a person's full name as First Name + Middle Initial + Last Name (e.g., Jane T. Doe).
Without Linked Generators
You could set up four Attributes and then use the ConcatGen Generator to combine them for the fullName Attribute.
- firstName
- middleInitial
- lastName
- fullName
However, the firstName, middleInitial, and lastName Attributes would then need to have the visibility Parameter set to false before generating data. Otherwise, these Attributes would also be in the generated test data.
Using Linked Generators
When Linked Generators are used, only one Attribute is needed: fullName Attribute. Within the fullName Attribute, we can define all four Generators as Linked Generators.
The Fourth Generator will use the ConcatGen Generator to combine the data generated by the first three Linked Generators.
Linked Generators generate their data in sequential order from the first Generator to the last Generator. Attributes may reference other Attributes that generate complex test data via Linked Generators, thus yielding even more complex test data.
Below is an example of the Linked Generator configuration for the fullName Attribute discussed in this example:
Here is a preview of the data generated by each Generator. Only the fullName will be included as part of the test data generated on the user's local computer.