Programmatic Access of Test Diagnostics
If you run tests with the runtests function or the run method of TestSuite or
TestCase, the test framework uses a DiagnosticsRecordingPlugin plugin that
records diagnostics on test results.
After you run tests, you can access recorded diagnostics via the DiagnosticRecord field
in the Details property on TestResult. For example, if your test results are stored in
the variable results, find the recorded diagnostics for the second test in the suite by
invoking records = result(2).Details.DiagnosticRecord.
The recorded diagnostics are DiagnosticRecord objects. To access particular types of
test diagnostics for a particular test, use the selectFailed, selectPassed,
selectIncomplete, and selectLogged methods of the DiagnosticRecord class.
By default, the DiagnosticsRecordingPlugin plugin records qualification failures and
logged events at the matlab.unittest.Verbosity.Terse level of verbosity. For more
information, see DiagnosticsRecordingPlugin and DiagnosticRecord.
Test Runner Customization
Use a TestRunner object to customize the way the framework runs a test suite. With a
TestRunner object you can:
- Produce no output in the command window using the withNoPlugins method.
- Run tests in parallel using the runInParallel method.
- Add plugins to the test runner using the addPlugin method.
For example,use test suite, suite, to create a silent test runner and run the tests with
the run method of TestRunner.
runner = matlab.unittest.TestRunner.withNoPlugins;
results = runner.run(suite);
Use plugins to customize the test runner further. For example, you can redirect output,
determine code coverage, or change how the test runner responds to warnings. For more
information, see “Add Plugin to Test Runner” on page 33-110 and the plugins classes.
See Also
TestRunner | TestSuite | matlab.unittest.constraints | plugins | selectors
See Also