You can verify model simulation by including a Test Assessment block in
your model or test harness, and authoring
verify statements in the
Test Assessment block.
verify statements return
for both the overall simulation and individual time steps. Results appear in the Test
verifyStatements in the Test Assessment Block
The Test Assessment contains a
When decomposition sequence helps you clearly define
the simulation condition that activates each
If your model uses a Test Sequence block source, consider
verify statement using the active Test
Sequence block step.
If your model does not use a Test Sequence block source, or
your test sequence steps do not correspond with conditions to verify, activate
verify statement using a signal condition.
verifyStatements with Test Sequence Steps
Connect the Test Sequence and Test Assessment block
with the active step signal from the Test Sequence block. Activate
verify statement with the active step.
For example, this test harness contains a Test Sequence and
Test Assessment block. The blocks are connected by the
The Test Assessment block contains a
decomposition sequence with four substeps. Each contains a
statement and is activated with a different Test Sequence block step.
To activate verify statements in a Test Assessment with active steps in a Test Sequence blocks:
Create active step data output for the Test Sequence block:
Select the Test Sequence block.
Create a new enumerated data output. In the Property Inspector, select Create data to monitor the active step.
Name the enumeration.
Create a data input for the Test Assessment block:
Open the Test Assessment block.
In the Symbols sidebar, next to Input, click the Add data icon.
Name the input.
In the block diagram, connect the Test Sequence block output to the Test Assessment block input.
When decomposition sequence in the Test
The Test Assessment block is configured by default with a
When decomposition sequence. To change
between a standard sequence and a
decomposition sequence, right-click the parent step and select
When decomposition step, define
when the step is active by using the active step enumeration
data. For example:
VerifyBoth when TSActiveStepIN == TSActiveStepEnum.PressBothButtons
verify statements to each assessment
verifyStatements with Signal Conditions
If your model does not use a Test Sequence block source, or if Test
Sequence steps do not correspond with conditions to verify, use unique signal
conditions to activate
verify statements. Place
verify statements in a
sequence, and use conditional statements in the
For example, this test harness uses a Signal Builder block input.
The Test Assessment block contains a
decomposition sequence. Each substep contains a
A unique signal condition activates each substep.
verify statements evaluate logical expressions. You can label
results in the Test Manager with optional arguments.
verify statement returns a
untested result for each time step
and for the overall simulation. A
fail at any
time step results in an overall
fail. If there are
no failing results, a
any time step results in an overall
Otherwise, the overall result is
untested. Results appear in the
Verify Statements section of the test results.
verify statements use the syntax:
verify(expression) verify(expression,errorMessage) verify(expression,identifier,errorMessage)
expressionis a logical expression. Use additional
arguments to define an
errorMessage and a statement
identifier. Error messages display in the diagnostic viewer.
You can use error messages to display key values at the time the statement
For example, if
verify evaluates an expression containing
y, you can display the values
y using the
'x and y values are %d, %d',x,y
An identifier labels the
verify results in the Test Manager.
The identifier uses a string of the form
suffix are alphanumeric
verify is not supported in Test Sequence
blocks that use continuous-time updating. Test Sequence block
data can depend on factors such as the solver step time. Continuous-time
updating can cause differences in when block data and
verify statements update, which can lead to
verify statement results.
If your model uses continuous time and you use
statements in a Test Sequence or Test
Assessment block, consider explicitly setting a discrete block
If you use parallel test execution to run your tests, then you cannot use
the Highlight in Model button for
In this comparison of two values, the parent step uses
statements to assess two local variables
y during the simulation.
verify(x >= y) passes overall because it is true for
the entire test sequence.
verify(x == y) and
verify(x ~= y)
fail because they fail in
The Test Manager displays the results: