Rule-Based Test Generation with Subflows
    • Dark
      Light

    Rule-Based Test Generation with Subflows

    • Dark
      Light

    Article Summary

    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:

    1. Embed a Subflow for which rules have been defined in a master model.
    2. Create a model-wide variable in the master flow.
    3. 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 of 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.
    4. 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":


    Next, you must link the variables in the Subflow to the Master Model. This converts 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 of the subflow level with one at the master flow level. This allows 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 allows 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: