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.
The MATLAB Test Manager displays tests in the currently open project. Organize your tests by using test suites and test tags.
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.
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
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.
Tests in the test manager have one of these statuses:
|Passed||The test completed without failures.||–|
|Failed||The test caused at least one failure or error to occur.|
The test failed because of a:
|Incomplete||The test did not run to completion.|
The test did not run to completion because of an assumption failure:
For more information, see
|Not Run||The test has not run.||
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:
View the failure diagnostic by clicking the hyperlink in the Diagnostic column. You can view detailed diagnostics by clicking the
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.
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.
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:
Apply a filter to the project or test suite. For more information about filtering tests, see Filter Test Results.
Press Shift or Ctrl and select the filtered tests.
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.