Main Content

Class-Based Unit Tests

Write class-based tests; parameterize tests; apply fixtures; select and run tests

Write xUnit-style tests to check that the output of MATLAB® code is as you expect. Class-based unit tests give you access to the full unit testing framework functionality. For example, you can write parameterized tests, tag your tests, or use shared test fixtures.

To get started, see Author Class-Based Unit Tests in MATLAB and Write Simple Test Case Using Classes.


runtestsRun set of tests
testsuiteCreate suite of tests
testrunnerCreate test runner
run (TestSuite)Run TestSuite array using TestRunner object configured for text output
run (TestRunner)Run all tests in TestSuite array
run (TestCase)Run TestCase test
runInParallelRun all tests in TestSuite array in parallel


matlab.unittest.TestCaseSuperclass of all matlab.unittest test classes
matlab.unittest.TestSuiteClass for grouping tests to run
matlab.unittest.TestSpecification of single test method
matlab.unittest.TestRunnerClass for running tests in matlab.unittest framework
matlab.unittest.TestResultResult of running test suite


matlab.unittestSummary of packages and classes in MATLAB Unit Test Framework
matlab.unittest.qualificationsSummary of classes in MATLAB Qualifications Interface
matlab.unittest.constraintsSummary of classes in MATLAB Constraints Interface
matlab.unittest.diagnosticsSummary of classes in MATLAB Diagnostics Interface
matlab.unittest.fixturesSummary of classes in MATLAB Fixtures Interface
matlab.unittest.parametersSummary of classes associated with MATLAB Unit Test parameters
matlab.unittest.pluginsSummary of classes in MATLAB Plugins Interface
matlab.unittest.selectorsSummary of classes in MATLAB Selectors Interface
Simulink.sdi.constraints.MatchesSignalConstraint that compares time series data with tolerances using the Simulation Data Inspector


Write Tests

Write Parameterized Test

Run Tests and Analyze Results