Create MATLAB Tests
R2026bSince R2023a
Use MATLAB Test™ to generate unit tests for source code from:
MATLAB scripts, functions, and classes
Statements in the Command History panel
Parts of the source code that were missed by existing tests
Requirements that implement MATLAB source code
You can also generate equivalence tests for MATLAB source code.
Additionally, you can create baseline tests to validate your MATLAB code against previously inspected data.
MATLAB Test extends the test authoring capabilities of the MATLAB unit testing framework. For more information, see Extend MATLAB Unit Testing Framework with MATLAB Test.
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) |
Functions
matlabtest.parameters.matfileBaseline | Define data in MAT file as baseline data (Since R2024b) |
verifyEqualsBaseline | Verify value is equal to baseline data (Since R2024b) |
Topics
- Create Starter 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 with Suggested Values for Function Inputs
Create tests with suggested input values to exercise a function without manually selecting test data. (Since R2026b)
- Generate Unit Tests Using MATLAB Copilot
Use MATLAB Copilot to generate unit tests that exercise your MATLAB source code. (Since R2025a)
- Generate Tests from Command History
Generate tests from previously executed commands in MATLAB. (Since R2025a)
- Generate MATLAB Tests from Missing Coverage
Improve code coverage by creating tests from parts of source code that were missed by existing tests. (Since R2026b)
- Generate MATLAB Tests from Requirements
Generate and link tests from requirements. (Since R2026b)
- Generate Equivalence Tests for MATLAB Functions
Generate equivalence tests that build and exercise generated code from the current function file. (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)