Test Sequence Basics
A test sequence consists of test steps arranged in a hierarchy. You can use a test sequence to define test inputs and to define how a test progresses in response to the simulation. A test step contains actions that execute at the beginning of the step. A test step can contain transitions that define when the step stops executing, and which test step executes next. Actions and transitions use MATLAB® as the action language. You create test sequences by using the Test Sequence block and the Test Sequence Editor. See Use Stateflow Chart for Test Harness Inputs and Scheduling.
Test Sequence Hierarchy
Test sequences defined in Test Sequence blocks can have parent steps and substeps. Substeps can activate only if the parent step is active. A group of steps in the same hierarchy level shares a common transition type. When you create a test step, the step becomes a transition option for other steps in the same group.
Test Sequence Scenarios
In a Test Sequence block, you can define multiple test sequences, which are called test sequence scenarios. By using scenarios, you can define distinct test sequences without having multiple Test Sequence blocks in your test harness. You can run test sequence scenarios in these ways:
Activate a single scenario from the Test Sequence Editor and run the model
Activate a single scenario using API commands and run the model
Control the active scenario with a workspace variable and run the model
Use a custom test script to loop through scenarios when running the model
Define iterations in the Test Manager to run more than one scenario in a single test case
For more information and examples of using test sequence scenarios, see Use Test Sequence Scenarios in the Test Sequence Editor and Test Manager and Programmatically Create and Run Test Sequence Scenarios.
Transition Types
Test sequences defined in Test Sequence blocks transition from one step to another in two ways:
Standard transition: You can define a sequence of actions that react to simulation conditions using a standard transition sequence. Standard transition sequences start with the first step and progress according to transition conditions and next steps. For a list of transitions, see Test Sequence and Assessment Syntax.
This test sequence sets the value of Boolean outputs
RedButtonIn
andGreenButtonIn
, with transitions happening after each step has been active for 1 sec.When decomposition:
When
decomposition sequences are analogous toswitch
statements in programming. In aWhen
decomposition sequence, steps activate based on specific conditions occurring in your model. You do not use transitions between steps. At each time step, the block evaluates the condition expression for each step sequentially. When the block reaches a step whose condition evaluates totrue
, the step becomes active and the subsequent steps remain untested.This When decomposition contains three
verify
statements. Eachverify
statement is active when the signalgear
is equal to a different value. For more information, see Verify Model Simulation by Using When Decomposition.
See Also
Related Topics
- Test Sequence Editor
- Test Sequence and Assessment Syntax
- Author a Test Sequence and Test Assessment
- Use Test Sequence Scenarios in the Test Sequence Editor and Test Manager
- Programmatically Create and Run Test Sequence Scenarios
- Verify Model Simulation by Using When Decomposition
- Use Stateflow Chart for Test Harness Inputs and Scheduling