If you have created Rules for an individual model, you can filter paths through that model when generating paths from a master model. This filters paths based on the model-level variable defined for the subprocess. It filters paths based on the values specified in rules assigned to the subprocess.
Rule-based generation with subflows is valuable when generating test suites for end-to-end or integrated testing. It creates consistent journeys across modelled components.
Having completed the steps in this article for defining Rules to a model, you must complete the following steps to apply rules to a master model containing subprocesses:
Embed a subflow for which rules have been defined in a master model.
Create a model-wide variable in the master flow.
Edit the Subflow properties to call the relevant subflow variables from the master flow. This will tell the path generation engine to override the variable the subflow level with one at the master flow level. If you link the variable used to filter paths at subflow level, this will allow you to enter values in a coverage profile at the master level, filtering paths based on the values assigned in rules at the subflow level.
Create a coverage profile that will filter paths based on the values associated with the test data variables specified in #3.
1. Embed a subflow with rules defined in a master flow
First, use this article to create embed your model as a subprocess in a master flow, connecting up any endpoints required.
2. Create a model-level variable with which to filter paths
Next, you must create a model-level variable in the mater flow. This will be used in the Coverage Profile to filter paths based on values at the subflow level. See this article for an overview of model-level variables and how they are used in rule-based test generation.
Note: You should keep separate the test data variables assigned to outputs, and the variable used to filter paths. 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":
3. Link the model-level variables in the subflow and master flow
Next, you must link the variables in the subflow the master flow. This convert the subflow variable into a parameter, allowing you to call it and filter paths in the subflow when generating paths from the master flow.
You must link the model-level variable used in the subflow to filter paths. This will let you filter paths in the master flow using the model-level variable you have created for this.
To link the model-level variables in the master and subflow, right click the relevant subflow and click "Subflow Properties":
Next, navigate to the "Parameters" tab and locate the model-level variable defined at the subflow level. This should have an intuitive, generic name like "Path type". Click the edit button beside it:
This will open the Data Editor window. Here, you can tell the path generation engine to override the variable the subflow level with one at the master flow level. This will allow you to enter values into a coverage profile, filtering paths based on values assigned in rules at the subflow level.
In the "Data Variable" column, locate the model-level variable that you have created at the master flow level. Select it and click "Insert Reference". You should then see the variable specified in the editor box:
Alternatively, you can type the parameter using the following syntax:
= [Path type]
Next, click "Save".
4. Create a Coverage Profile with which to filter paths
Now, you can call the subflow variable from the master flow. You can therefore create a coverage profile that will filter paths based on rules assigned to outputs in the subflows.
Note: These nodes must have rules assigned. These rules must contain the variable linked to the master flow and the values with which you wish to filter paths. See this article for an overview of model-level variables and how they are used in rule-based test generation.
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. This will allow you to quickly switch between your Profiles, rapidly generating different sets of paths:
Next, click "Coverage". 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. This should be called something like "Path type".
To generate only paths that pass through certain outputs in the subflow, specify that value in the "value" field:
In the above example, all paths that pass-through nodes/outputs with the value "Admin" assigned to them in the subflow will be included in generation:
TEST MODELLER TEST CASE GENERATION