Main Content

Run Unit Tests

Select and run tests; customize the test runner; analyze test and coverage results

Run your tests interactively in the MATLAB® Editor or Live Editor, or in the Test Browser app, or run your tests programmatically, for example, with the runtests function or the run method of the matlab.unittest.TestSuite class. Customize your test run with options, such as running tests in parallel (requires Parallel Computing Toolbox™) or specifying a level of test output detail. Collect code coverage metrics as you run your tests, and analyze the test and coverage results.

Apps

Test BrowserRun MATLAB tests and view results (Since R2023a)

Functions

runtestsRun set of tests
testsuiteCreate suite of tests
testrunnerCreate test runner (Since R2021a)
run (TestSuite)Run test suite using default test runner
run (TestRunner)Run test suite
run (TestCase)Run tests corresponding to test case
runInParallelRun all tests in test suite in parallel

Classes

matlab.unittest.TestCaseSuperclass of all test classes
matlab.unittest.TestSuiteFundamental interface for grouping tests to run
matlab.unittest.TestSpecification of a single test
matlab.unittest.TestRunnerClass for running tests in unit testing framework
matlab.unittest.TestResultResult of running test suite
matlab.coverage.ResultResult of code coverage analysis (Since R2023a)

Namespaces

matlab.unittestSummary of classes and namespaces in MATLAB unit testing framework
matlab.unittest.pluginsSummary of classes in MATLAB plugins interface
matlab.unittest.selectorsSummary of classes in MATLAB selectors interface

Topics

Run Tests

Analyze Results