The process for rule-based test generation is as follows for an individual model:
Identify relevant decision gates in your model. A 'relevant decision gate' is one with which you want to filter paths based on its outputs.
Create a model-level variable with which to filter paths.
Create rules for every node (output) in the relevant decision gate. The rule informs the path generator when it should include paths that pass through the node, based on data values set in the rule. The rule use the variable created in step 2.
Create a coverage profile to filter paths based on the test data values. This coverage profile will generate paths that pass-through blocks with certain values contained in their rule. It uses the model-level variable created in step 2.
Generate test cases from the model. This will force the test generation engine down the paths with values included by the rules and coverage profile.
1. Identify relevant decision gates in your model
Rules force the path generator down certain routes, following one or more Decision Gate in a model. The outputs are blocks/nodes which have rules assigned to them.
Each output in the Decision Gate must have a Rule assigned. The Rules contain particular Data Values. A Coverage Profile then forces the path generator to follow paths with certain values assigned in their Rules.
In Test Modeller, a Decision Gate is modelled using a yellow Condition Block. The subsequent blocks/nodes specify the outputs for the decision. For example, the below model reflects a user log-in. It contains a Decision Gate where the outputs reflect the different types of user:
A rule can be used in this instance to force test generation down either decision. For example, the model might be connected into a master model. You might then want to execute a set of tests only as an "Admin" user, generating tests that pass only through the Admin output from the decision-gate.
Note: You should tag every block in a given Decision Gate with a rule. Action block without values defined will automatically be included during test generation, potentially generating unwanted test cases.
2. Create a model-level variable with which to filter paths
Next, you must create a model-level variable with which to filter paths. This variable will be used in Rules, assigned to relevant outputs, and in a Coverage profile. The Coverage profile will filter paths based on values and their corresponding rules, both of which have been assigned to the modelled outputs.
Note: You should keep separate the test data variables used to assign data values at the model level, and the variable used to filter paths in coverage profiles. Do not use a variable to assign test data values to blocks at the model level and also to filter paths during generation. This risks creating ambiguity in the Boolean logic used to filter paths based on test data values.
It is best practice to name the model-level variable intuitively, for instance naming it "Path type":
This makes it clear that it is used to filter path generation based on test data outputs, but is not used to assign values.
Note: When creating a model-level data variable for a subflow that you want to call from a master flow, you must select "Expose as Flow Parameter" to use that variable in a rule at the master flow level. In the Variable editor, click "Advanced" to expand the options and then select "Expose as Flow Parameter":
Follow this article for full instructions on creating a variable.
3. Create a rule for every output for each relevant Decision Gate
To force path generation through certain outputs associated with a Decision Gate, every output in the Decision Gate must have a "Rule" associated with it.
Rules use Boolean logic to define when a node (output) should be included in path generation. They specify values for that output. If the specified values are then included in a Coverage Profile, paths passing through that node will be included in test generation.
To assign a rule, select an Action block in your model. Then, navigate to the "Test Generation" tab of the menu and then click "Rules":
Next, click "Add Condition" to enter one or more conditions that will inform one or more Rule. First, use the first drop-down to specify the model-level variable that you have created to filter paths (step two above). This should be called something like "Path type":
To filter path generation to include or exclude the selected Output, use the let-sided Dropdown to Select the Variable assigned to the decision block.
Next use the right-sided drop-down to set the Test Data Value. Set the test data value assigned to the node for the given variable. When you later create a coverage profile, you can then use the variable to filter based on this value assigned to the block.
It's best practice to also specify what should happen if the value in the Coverage Profile is not found during test generation. This ensures that the Boolean logic used to filter paths during generation is complete and unambiguous, avoiding erroneous path generation.
First, change the condition from an AND to an OR, using the drop-down:
Next, click "Add Condition" and specify a value name. This value should be used across all rules for the Decision Gates in the model. That way, you can also set a Coverage Profile that will include all nodes with "Not set" as their value. This can be useful when filtering for large models.
The value name should be intuitive, and one best practice is to name it "Not set":
You can assign multiple values to a Rule. In this instance, whenever one specified value is included in a Coverage Profile, the node will be included in the generated paths. If assigning multiple values, you must set the rule to "OR":
In the above example, the node with this rule will be included in path generation whenever the following three values are specified in a coverage profile: "Admin", "Not set", "Super user.
Note: You must create rules for every output for each relevant decision gate.
You will see the "Rule" symbol for every node when a Rule is set:
4. Create a Coverage Profile with which to filter paths
Next, you must create a new Coverage Profile to filter paths using the model-level variable created during step 2 above. This will filter paths based on rules and the associated values which you have assigned to outputs in your model.
First, navigate to the "Test Generation" tab of the menu and then click "New" under the coverage profile drop-down. Creating a new coverage profile will allow you to quickly switch between your Profiles, rapidly generating different sets of paths:
Next, click "Coverage" to define the coverage profile. To generate paths based on values and rules defined at the model, navigate to the "Variables" tab when defining the Coverage Profile:
Click "Add" to enter a new filter. Specify the model-level variable that you created to filter paths (see step 2 above). This should be called something like "Path type".
To generate only paths that pass through certain outputs in the model, you can specify the test data value contained in those outputs (see step 1 above). Specify the relevant value in the "Value" field:
In the above example, all paths that pass-through nodes/outputs with the value "Admin" defined in a Rule will be included in generation.
Click "Save" and then click "Generate" to create paths based on the defined Rule. See this Knowledge Base article for full instructions on test generation.
In the above example, only one path has been generated – the path through the "Admin" output:
In the above example, all outputs have "Not set" as one of the conditions in their rule. If the Coverage Profile instead specifies "Not set" as its value, all three paths are included in the generation:
TEST MODELLER TEST CASE GENERATION