Main Content

Manage Tests and Results by Using the MATLAB Test Manager

Manage MATLAB® tests and test results for Projects by using the MATLAB Test Manager. You can:

  • Organize tests by creating test suites and using test tags.

  • Run tests and view a summary of the results.

  • Investigate test results by viewing failure diagnostics and using filters.

  • Run subsets of tests by using test suites, test selections, and filters.

For more information about authoring MATLAB tests, see Ways to Write Unit Tests.

To open the test manager, first open a project. Then, in the Project tab, in the Tools menu, under Apps, click MATLAB Test Manager.

Organize Tests

The MATLAB Test Manager displays tests in the currently open project. Organize your tests by using test suites and test tags.

Test Suites

Test suites are groups of tests that share common criteria. You can create and save test suites by using the Test Suite Manager. For more information, see Create and Run Test Suites.

The Test Suite Manager shows a test suite called InputTests that is created from tests that have the InputTests tag.

You can create test suites from:

  • Tests in a folder

  • Tests that have a specific test tag or tests from multiple tags

  • Selectors by using constructors for classes in matlab.unittest.selectors or matlabtest.selectors

Test Tags

Use test tags to group tests into categories. Typical test tags identify a feature about the code under test or describe the type of test. For more information, see Tag Unit Tests.

Run Tests and View Results

To run all tests in the project, click the Run button .

You can collect coverage when you run all tests in the project. For more information, see Collect Coverage.

You can customize your run by setting test options. For more information, see Customize Test Run.

The MATLAB Test Manager displays the test results from the last time each test was run. Test results include status, duration, and a diagnostic for failed and incomplete tests.

The test result summary aggregates the status of the tests in the project or test suite from the last time the tests were run. The Test Details table displays detailed test results.

MATLAB Test Manager window with 14 passed tests and 1 failed test spread across 2 test files.

Tests in the test manager have one of these statuses:

PassedThe test completed without failures.
FailedThe test caused at least one failure or error to occur.

The test failed because of a:

  • Verification failure

  • Assertion failure

  • Fatal assertion failure

  • Syntax error in the test or source code that the test called.

IncompleteThe test did not run to completion.

The test did not run to completion because of an assumption failure:

  • In the test function.

  • In the method-level setup or teardown for the test function.

  • In the class-level setup or teardown. The test manager marked all tests in the test file as incomplete.

For more information, see matlab.unittest.qualifications.Assumable.

Not RunThe test has not run.
  • You have not run this test.

  • You ran the test, but a fatal assertion failure occurred before this test was run. The failure caused the test manager to abort the test run. For more information, see matlab.unittest.qualifications.FatalAssertable.

For more information about qualifications, see Table of Verifications, Assertions, and Other Qualifications.

Investigate Test Results

Use the Test Details table to view details about the test results. Investigate test results by using filters to view:

  • Only the failed tests

  • Tests that have a specific failure diagnostic

  • Results for tests with specific tags

  • Results for tests linked to specific requirements

Investigate failed tests by using information in the Test Details table.

Filter Test Results

To filter tests by test results, click the Passed, Failed, Incomplete, or Not Run buttons in the test result summary. Alternatively, above the Test Details table, click the Filters button and select which test results to filter by.

To filter by text, enter text in the Filter by text box. This filter searches the table and returns only the rows that contain the search term.

Investigate Failed Tests

To investigate and fix failed tests:

  1. View the failure diagnostic by clicking the hyperlink in the Diagnostic column. You can view detailed diagnostics by clicking the FAIL hyperlink.

  2. Open the failed test in the MATLAB Editor by clicking the test hyperlink in the failure diagnostic or in the Test column of the Test Details table.

  3. Fix the test failure by making changes to the test or to the source code under test. For more information, see Analyze Failed Test Results.


    Run the test without leaving the editor by using the Test Browser. For more information, see Run MATLAB Tests.

  4. Run the fixed test and other related tests by using the MATLAB Test Manager.

Run Subsets of Tests

When you add new tests or fix failed tests, you can run only the relevant tests by:

  • Running a test suite

  • Running a single test or test file

  • Running a selection of multiple tests

  • Applying filters and running a selection of tests

Run Test Suites

To open a test suite, click All Tests in Current Project, then select a test suite from the menu.

To run all tests in the test suite, click the Run button .

Run Selected Tests

To run a single test or all tests in a single file, right-click the test or test file and select Run selected. Alternatively, next to the Run button , click the Expand icon and select Run selected.

To run a selection of multiple tests, press Shift or Ctrl and select the tests, then right-click and select Run selected.

Run Filtered Tests

To run a subset of tests by using filters:

  1. Apply a filter to the project or test suite. For more information about filtering tests, see Filter Test Results.

  2. Press Shift or Ctrl and select the filtered tests.

  3. Right-click the selection and select Run selected.


Clicking the Run button runs all tests in the project or test suite even when filters are applied.

See Also


Related Examples

More About