Extend MATLAB Unit Testing Framework with MATLAB Test
MATLAB® Test™ extends the functionality of the MATLAB unit testing framework. For example, with MATLAB Test, you can:
Measure the decision coverage, condition coverage, and modified condition/decision coverage (MC/DC) of your source code.
Filter a test suite by source code dependency.
Create and run a suite of tests that verify requirements (requires Requirements Toolbox™).
Run tests by using
This topic provides a summary of how MATLAB Test extends the functionality provided by existing MATLAB apps, functions, and classes. For more information about the MATLAB unit testing framework, see Ways to Write Unit Tests.
Measure Decision Coverage, Condition Coverage, and MC/DC
The unit testing framework lets you measure the statement coverage and function
coverage of your MATLAB source code. You can collect and access these metrics either
programmatically by using the
class or interactively by using the Test Browser
app. If you have MATLAB
Test installed, you can use
CodeCoveragePlugin and Test
Browser to also measure the decision coverage, condition coverage, and MC/DC
of your source code.
Filter Test Suite by Source Code Dependency
If you have MATLAB
Test installed, you can filter a test suite by test file dependency on
specified source code. To specify the source files and folders, use the
matlabtest.selectors.DependsOn class or the
name-value argument. You can specify the
argument for these methods and functions of the unit testing framework:
Create and Run Suite of Tests That Verify Requirements
If you have MATLAB
Test and Requirements Toolbox installed, you can create a test suite from tests that verify requirements
matlab.unittest.TestSuite.fromRequirements, which is a static method of
matlab.unittest.TestSuite class. You also can use the
runtests functions to
respectively create a suite of tests and run tests that verify requirement sets.
Run Tests Using
" Parameter Combination
When you pass more than one parameterization property to a method of a
Test can invoke the method for every
-tuple of parameter values. To use
this type of parameter combination, specify the
attribute of the method as
is an integer between 2 and 10.
" parameter combination