Create and Run MATLAB Tests
Create and run tests and test suites interactively and programmatically
Since R2023a
Since R2023a
MATLAB® Test™ extends the capabilities of the MATLAB unit testing framework. For example, you can:
Automatically create test classes to exercise MATLAB source code.
Run test suites based on file dependencies and requirement links.
Run tests in projects by using the MATLAB Test Manager app.
For more information on how MATLAB Test extends the functionality provided by MATLAB apps, classes, and functions, see Extend MATLAB Unit Testing Framework with MATLAB Test.
Apps
MATLAB Test Manager | Manage MATLAB tests and results for projects |
Classes
matlabtest.parameters.BaselineParameter | Baseline parameter (Since R2024b) |
matlabtest.baselines.MATFileBaseline | Representation of baseline data stored in MAT file (Since R2024b) |
matlabtest.constraints.EqualsBaseline | Test if value is equal to baseline data (Since R2024b) |
matlabtest.selectors.HasBaseline | Select TestSuite array elements by baseline-specific
parameterization (Since R2024b) |
matlabtest.selectors.DependsOn | Select TestSuite array elements by source code
dependency |
Functions
matlabtest.parameters.matfileBaseline | Define data in MAT file as baseline data (Since R2024b) |
verifyEqualsBaseline | Verify value is equal to baseline data (Since R2024b) |
matlab.unittest.TestSuite.fromRequirements | Create test suite from requirements |
Topics
Write Tests
- Create Basic Tests for MATLAB Source Code
Generate a starter test class that exercises your script, function, or class. Use the class as a starting point for adding more tests. (Since R2024a) - Generate Tests for MATLAB Source Code
Generate unit tests that exercise your MATLAB source code or equivalence tests that build and exercise generated code. (Since R2025a) - Create Baseline Tests for MATLAB Code
Verify that a MATLAB function continues to produce the same outputs by creating and running a baseline test. (Since R2024b)
Run Tests
- Run MATLAB Tests
Run MATLAB tests programmatically or by using the MATLAB Editor, Test Browser, or MATLAB Test Manager. - Manage Tests and Results by Using the MATLAB Test Manager
Manage tests and test results for projects by using the MATLAB Test Manager. - Find Tests That Depend on Files
Find and run tests that depend on files and folders interactively or programmatically. - Find and Run Impacted Tests in Projects Under Source Control
Use the MATLAB Test Manager to find and run tests impacted by changes since the last commit. (Since R2025a) - Run Impacted Tests Using MATLAB Build Tool
Run the tests impacted by changes to code and data by using the MATLAB build tool. (Since R2025a) - Configure Test Settings for Build Tool by Using MATLAB Test Manager
Use test and coverage settings from the MATLAB Test Manager when you use the MATLAB build tool to run tests. (Since R2025a)