test model against requirements and report results
requirements – test traceability overview
traceability between requirements and test cases helps you interpret test results and see the
extent to which your requirements are verified. you can link a requirement to elements
that help verify it, such as test cases in the test manager, verify
statements in a test sequence block, or model verification blocks in a
model. when you run tests, a pass/fail summary appears in your requirements set.
this example demonstrates a common requirements-based testing workflow for a cruise control model. you start with a requirements set, a model, and a test case. you add traceability between the tests and the safety requirements. you run the test, summarize the verification status, and report the results.

in this example, you conduct a simple test of two requirements in the set:
that the cruise control system transitions to disengaged from engaged when a braking event has occurred
that the cruise control system transitions to disengaged from engaged when the current vehicle speed is outside the range of 20 mph to 90 mph.
display the requirements
open the example project.
openexample("shared_vnv/cruisecontrolverificationprojectexample"); pr = openproject("simulinkverificationcruise");
in the
modelsfolder, open thesimulinkcruiseaddreqexamplemodel.display the requirements. click the
icon in the lower-right corner of the model
canvas, and select requirements. the requirements appear
below the model canvas. display the verification and implementation status. right-click a requirement and select verification status and implementation status.

in the project window, open the simulink® test™ file
slreqtests.mldatxfrom thetestsfolder. the test file opens in the test manager.
link requirements to tests
link the requirements to the test case.
in the project window, open the simulink test file
slreqtests.mldatxfrom thetestsfolder. the test file opens in the test manager. explore the test suite and selectsafety tests.return to the model. right-click on requirement
s 3.1and select link from selected test case.a link to the
safety teststest case is added to verified by. the yellow bars in the verified column indicate that the requirements are not verified.
also add a link for item
s 3.4.
run the test
the test case uses a test harness safetytest_harness1. in the test
harness, a test sequence sets the input conditions and checks the model behavior:
the
braketestsequence engages the cruise control, then applies the brake. it includes theverifystatementverify(engaged == false,... 'verify:brake',... 'system must disengage when brake applied')
the
limittestsequence engages the cruise control, then ramps up the vehicle speed until it exceeds the upper limit. it includes theverifystatement.verify(engaged == false,... 'verify:limit',... 'system must disengage when limit exceeded')
return to the test manager. to run the test case, click run.
when the test finishes, review the results. the test manager shows that both assessments pass and the plot provides the detailed results of each
verifystatement.
return to the model and refresh the requirements. the green bar in the verified column indicates that the requirement has been successfully verified.

report the results
create a report using a custom microsoft® word template.
from the test manager results, right-click the test case name. select create report.
in the create test result report dialog box, set the options:
title —
safetytestresults for —
all testsfile format —
docxfor the other options, keep the default selections.
enter a file name and select a location for the report.
for the template file, select the
reporttemplate.dotxfile in the documents project folder.click create.
review the report.
the test case requirements section specifies the associated requirements
the verify result section contains details of the two assessments in the test, and links to the simulation output.
related topics
- (simulink test)