Test case class for MATLAB-based Simulink tests integrated with Test Manager
sltest.TestCase class enables authoring MATLAB®-based Simulink® tests. You define a MATLAB-based Simulink test in a
.m file that inherits from
sltest.TestCase is a
and behaviors are available when authoring a MATLAB-based Simulink test.
sltest.TestCase class is a
For information on class attributes, see Class Attributes.
To create a test that you can load, run, and analyze its results in the Test Manager,
create a class definition file that inherits from
sltest.TestCase. The file
contains methods that define the test case.
For debugging at the command line without having to run an
test, use the
forInteractiveUse static method to create a
In addition to the listed methods, the
sltest.TestCase class can use the
methods of the
|Load model for MATLAB-based Simulink test|
| Simulate model or |
|Create temporary folder|
|Create test case for interactive use|
|Assume two data sets are equivalent|
|Assert two data sets are equivalent|
|Fatally assert two data sets are equivalent|
|Verify two sets of data are equivalent|
myBaselineTest.m class definition file
defines a test case that compares a set of baseline values and values produced from a
simulation using the
simulate method. See Using MATLAB-Based Simulink Tests in the Test Manager for the full example
that includes the baseline data file and other files and commands required to run this
test and then load it into the Test Manager.
The first line of the file shows the inheritance from
The method section, which has a Test attribute, contains the
test case. The test case loads a model, sets some variable values, simulates the model,
and tests whether the simulation and baseline signals match.
classdef myBaselineTest < sltest.TestCase methods (Test) function testOne(testCase) testCase.loadSystem('sltest_ratelim'); in = Simulink.SimulationInput('sltest_ratelim'); in = in.setVariable('t_gain',[0;2], 'Workspace','sltest_ratelim'); in = in.setVariable('u_gain',[-0.02;-4.02], 'Workspace','sltest_ratelim'); simOut = testCase.simulate(in); testCase.verifySignalsMatch(simOut,'baseline1.mat'); end end end