Main Content

Test Sequence Editor

The Test Sequence Editor enables you to define and modify test sequences for Test Sequence and Test Assessment blocks. To open the Test Sequence Editor, double-click a Test Sequence or Test Assessment block.

Define Test Sequences

A test sequence consists of test steps arranged in a hierarchy. Test steps can contain transitions that define how a test progresses in response to the simulation. Test steps can also have a When decomposition that uses logic similar to an if-elseif-else statement. By default:

  • New Test Sequence blocks contain two standard transition test steps.

  • New Test Assessment blocks contain a When decomposition test step with two sub-steps.

For more information, see Transition Types.

To define a test sequence:

  1. Add test steps, as described in Manage Test Steps.

  2. In the Step cell, define outputs and assessments.

  3. To add a transition from a test step:

    1. Point to the Transition cell and click Add transition.

    2. In the Transition cell, define the conditions for exiting the step.

    3. In the Next Step cell, select the next test step from the drop-down list.

  4. To define a step with a When decomposition:

    1. Right-click a test step and select When decomposition. The step displays the icon .

    2. Add sub-steps, as described in Manage Test Steps.

    3. In the Step cell of each sub-step, enter the when operator, followed by a condition. Do not add a condition to the last sub-step.

Test Sequence Scenarios

To define multiple test sequences in a single Test Sequence block, use scenarios. In the left pane of the Test Sequence Editor, click Scenarios, then click Use Scenarios. The existing test steps and transitions are moved into a scenario tab named Scenario_1. Add more scenarios to define more test sequences. For more information on Test Sequence scenarios, see Use Test Sequence Scenarios in the Test Sequence Editor and Test Manager.

Manage Test Steps

In the Test Sequence Editor, you can add and delete test steps to your test sequence. You can also reorder the test steps and change their position in the hierarchy.

Add and Delete Test Steps

To add a test step, right-click an existing step and select Add step before or Add step after.

To add a test step in a lower hierarchy level, right-click the parent step and select Add sub-step.

To delete a test step, right-click the step and select Delete step. If the test sequence contains only one test step, you cannot delete it. You can delete its contents by selecting Erase last step content.

Copy and Paste Test Steps

To copy a test step, right-click the area to the left of the step name and select Copy step. Alternatively, select the test step and use the shortcut Ctrl+C.

To cut a test step, right-click the area to the left of the step name and select Cut step. Alternatively, select the test step and use the shortcut Ctrl+X.

To paste a test step, right-click the area to the left of a step name and select Paste step, then:

  • Paste before step

  • Paste after step

  • Paste sub-step

Alternatively, select the test step and use the shortcut Ctrl+V.

Reorder Test Steps and Transitions

To reorder the test steps in a test sequence:

  1. Point to a test step. The icon appears to the left of the step name.

  2. Click and drag the icon to reorder the test step.

You can reorder test steps within the same hierarchy level. When you move a test step, sub-steps move with the test step.

Test Sequence step with reorder step tooltip

To reorder a transition within the same test step, click and drag the transition number to the new location. The corresponding next step moves with the transition.

Test Sequence step transition with reorder transition tooltip

Change Test Step Hierarchy

To move a test step to a lower level in the hierarchy, right-click the step and select Indent step. You can only indent a test step when the preceding step is at the same hierarchy level. You cannot indent the first test step in a sequence or the first step in a hierarchy group.

To move a test step to a higher level in the hierarchy, right-click the step and select Outdent step. You can only move the last step in a hierarchy group to a higher level in the hierarchy.

Manage Input, Output, and Data Objects

In the Symbols sidebar of the Test Sequence Editor, you add, edit, or delete symbols in the Test Sequence block. You can access these symbols from test steps at any hierarchy level. To show or hide the Symbols sidebar, click the Symbols Sidebar button on the Test Sequence Editor toolbar.

Test Sequence editor symbols pane

To add a data symbol, point to the node for a symbol type and click an add symbol button. Available options and additional setup steps depend on the symbol type.

Symbol TypeDescriptionProcedure for Adding Symbol
Input

Options for input entries include:

  • Data

  • Messages

  1. In the Symbols sidebar, point to the Input node and click either:

    • Add data

    • Add message

  2. Enter the name of the input and press Enter.

Output

Options for output entries include:

  • Data

  • Messages

  • Function Calls

  • Triggers

  1. In the Symbols sidebar, point to the Output node and click:

    • Add data

    • Add message

    • Add function call

    • Add trigger

  2. Enter the name of the output and press Enter.

Local

Local data entries are available only inside the Test Sequence block in which they are defined.

  1. In the Symbols sidebar, point to the Local node and click Add data.

  2. Enter the name of the local variable and press Enter. Initialize the local variable in the first test step.

Constant

Constants are read-only data entries available only inside the Test Sequence block in which they are defined.

  1. In the Symbols sidebar, point to the Constant node and click Add data.

  2. Enter the name of the constant and press Enter.

  3. Point to the name of the constant and click Edit.

  4. In the dialog box, in the Constant Value field, enter the value of the constant.

Parameter

Parameters are available inside and outside the Test Sequence block.

  1. Using the Model Explorer, add a parameter in the workspace of the model that contains the Test Sequence block.

  2. In the Symbols sidebar, point to the Parameter node and click Add data.

  3. Enter the name of the parameter and press Enter.

Data Store Memory

Data Store Memory entries are available inside and outside the Test Sequence block.

  1. Using the Model Explorer, add a Simulink.Signal object in the workspace of the model that contains the Test Sequence block. Alternatively, add a Data Store Memory block to the model. To set or modify global parameters in the Test Sequence block, you can use Simulink.Signal objects as Data Store Memory.

  2. In the Symbols sidebar, point to the Data Store Memory node and click Add data.

  3. Enter the name of the data store and press Enter.

To edit a data symbol, point to the name of the symbol and click Edit.

To delete a data symbol, point to the name of the symbol and click Delete.

Find and Replace

You can find and replace text in Test Sequence actions, transitions, and descriptions by using the Find & Replace tool in the Test Sequence Editor.

  1. To open the Find & Replace tool, click the icon in the toolbar.

  2. In the Find what field, enter the text you want to locate.

  3. In the Replace with field, enter the updated text.

  4. To locate the text, click Find Next or Find Previous.

  5. To replace the old text with the updated text, click Replace.

When running a search, the Find & Replace tool searches descriptions only if the description column is open.

Automatic Syntax Correction

The Test Sequence Editor changes the syntax automatically for:

  • Increment and decrement operations, such as a++ and a--. For example, a++ is changed to a=a+1.

  • Assignment operations, such as a+=expr, a–=expr, a*=expr, and a/=expr. For example, a+=b is changed to a=a+b.

  • Evaluation operations, such as a!=expr and !a. For example, a!=b is changed to a~=b.

  • Explicit casts for literal constant assignments. For example, if y is defined as type single, then y=1 is changed to y=single(1).

Output and View Active Step Data

When you run a test, the current step in the test sequence is the active step. When you enable creating active step data, a new output port is added to the Test Sequence block for the active step signal. You can analyze the active step data or use the output signal as an input to other blocks in your test harness. For example, a Test Assessment block can use the active step input as a trigger signal. You can also plot the active step data in the Simulation Data Inspector to see how the active step changes over time.

Enable Active Step Output

To create the active step data:

  1. From the Test Sequence Editor, open the Model Explorer. Alternatively, open the Property Inspector from the test harness or model that contains the Test Sequence or Test Assessment block.

  2. Enable Create data to monitor the active step.

    Active step output option with string data type

  3. Set Data Type to String or Enum. The default value is String.

    • String — Output the active step data as a string. Use this option if you use duplicate step names across scenarios or if you use duplicate substep names in different steps of the same scenario. When you select String, the output includes the step name and indicates which scenario is active. The step name string is <scenario>.<step>.<substep>. If the block does not have an active step at a time step, the output is an empty string. This situation might occur if a step uses an enabled subsystem and that subsystem is not enabled during that time step.

    • Enum — Output the active step as an enumerated value. Selecting Enum enables the Enum name parameter. The data is output in the format <Enum name>.<step name>. The scenario of that step is not included in the active step name. You cannot use Enum for the active step output if you have duplicate step or substep names in your test sequence.

      Active step output option with enum data type

  4. Click Apply.

View Active Step Data

You can view the active step output data in the Simulation Data Inspector, or if you run your test in the Test Manager, in the Test Manager Results pane. Before running the test, in the harness, right-click the active data output signal of the Test Sequence block and click Log Selected Signal. If you want to plot the active step output, you do not need to connect the active step output signal to any component.

After running a test, open the Simulation Data Inspector or the Test Manager Results. The format of the active step plot differs depending on whether the output is an enumerated or string type.

  • Enumerated type — The x-axis is time and the y-axis is the step.

    Sample plot of active step output as an enumerated type

  • String type — The x-axis is time. Steps appear as blocks of time during the period they are active. If there is not enough space to show the full string names, the Simulation Data Inspector truncates the beginning of the names so the step name displays.

    Sample plot of active step output as a string type

    If there are too many step blocks to display in the plot, only the steps that fit are shown.

You can add the active step data plot to a Test Results report in the same way you include other test results.

Use Active Step Output as Input to Another Block

To use the active step output signal as input to another block, such as a Test Assessment block, connect the signal to the input port of the block. You can then use the signal to trigger actions and assessments based on the active step.

See Also

|

Related Topics