Main Content

Debug a Test Sequence

This example shows how to debug a test sequence using tools in the Test Sequence Editor. Debugging involves setting breakpoints to stop simulation, observing data and test sequence progression, and manually stepping through test steps.

Open the model and the Test Sequence Editor block

open_system('TestSeqDebug/Test Sequence')

View Test Step Execution During Simulation

By default, simulation animates the test sequence by highlighting active steps and transitions. Observing test step execution can help you debug, particularly when manually stepping through the test sequence. Adjust the animation speed using the Change Animation Speed button test_seq_editor_change_animation_speed.png in the toolbar.

Animation speed affects simulation speed. If you slow down animation speed for debugging, return the speed to Fast or Lightning Fast when you finish debugging to avoid slowing your simulation. If you do not need the test step highlights and want the fastest simulation, choose None.

Set Breakpoints to Enable Debugging

Enable debugging for a test sequence by adding one or more regular or conditional breakpoints. Regular breakpoints halt simulation every time the test step is evaluated. Therefore, breakpoints on some test steps, such as When decomposition parent steps, halt simulation repeatedly because the step is evaluated repeatedly. Conditional breakpoints halt simulation only when the specified condition is met. When simulation halts, you can view the data used in the test sequence to investigate the sequence simulation behavior.

You can add regular and conditional breakpoints to test step actions and transitions.

  • To add a regular breakpoint to a test step, right-click the step or action and select Break while executing step. For a transition, point to the transition, click the gear icon , and select Break when transition taken. A red icon indicates a regular breakpoint.Regular breakpoint for a step

Regular breakpoint for a transition

  • To add a conditional breakpoint, first add a regular breakpoint. Then, right-click the breakpoint icon and select Set or Modify Condition.In the text field of the dialog box, specify the condition to apply to the step or transition and click Apply Condition. To indicate that it is a conditional breakpoint, the icon color changes to yellow.

Dialog for specifying breakpoint condition

  • To change a conditional breakpoint back to a regular breakpoint, right-click the breakpoint icon and select Set or Modify Condition. Delete the conditional text and click Apply Condition. The breakpoint icon color changes to red.

  • You can remove a breakpoint using these methods:

  • Click the breakpoint icon.

  • Right-click the breakpoint icon and select Clear Breakpoint.

  • For a step or action, right-click the step breakpoint icon and deselect Break while executing step. For a transition, point to the transition, click the gear, and deselect Break when transition taken.

After adding breakpoints, simulate the test sequence by clicking Run.

View Data Values During Simulation

If the simulation pauses (for example, at a breakpoint), you can view the status of data used in a test step by hovering over the test step. The data values at the current simulation time display next to the test sequence cell.

Data status for a test step

If you advance the simulation to another stop (for example, using the keyboard shortcuts), the data display does not update. Move off the test step and then hover over the step again to refresh the values.

Step Through Simulation

When simulation halts, you can step through the test sequence using these toolbar buttons.

test_seq_editor_run_button.png Simulate until breakpoint - Simulation runs until the next breakpoint

test_seq_editor_step_forward_button.png Step forward through simulation time - Simulation advances one simulation step

test_seq_editor_step_over_button.png Step forward through test step actions and transitions - Simulation advances by each step of a test sequence, with pauses at actions and transitions. Does not step into a function call.

test_seq_editor_step_in_button.png Step in to a test step group or called function - Simulation advances into the substeps of a parent step and executes each action and transition. Steps into a function call.

test_seq_editor_step_out_button.png Step out of a test step group or called function - Simulation advances through the remaining substeps of a parent step and then out to the parent step hierarchy level. Also finishes execution of a function call.

See Also