Programmatically Access Test Diagnostics - MATLAB & Simulink (original) (raw)
Main Content
In certain cases, the testing framework uses a DiagnosticsRecordingPlugin instance to record diagnostics on test results. The framework uses the plugin by default if you take any of these actions:
- Run tests using the runtests function.
- Run tests using a default test runner created with the testrunner function or the withDefaultPlugins static method.
- Run tests using the
run
method of the TestSuite or TestCase class. - Run performance tests using the runperf function or the
run
method of the TimeExperiment class.
After your tests run, you can access recorded diagnostics using theDiagnosticRecord
field in the Details
property of TestResult objects. For example, if your test results are stored in the variable results
, thenresult(2).Details.DiagnosticRecord
contains the recorded diagnostics for the second test in the suite.
The recorded diagnostics are DiagnosticRecord objects. To access particular types of test diagnostics for a test, use the selectFailed
,selectPassed
, selectIncomplete
, andselectLogged
methods of the DiagnosticRecord
class.
By default, the plugin records failing events and events logged at thematlab.automation.Verbosity.Terse
level. To record passing diagnostics or messages logged at higher verbosity levels, create an instance ofDiagnosticsRecordingPlugin
and add it to the test runner.
See Also
Classes
- matlab.unittest.plugins.DiagnosticsRecordingPlugin | matlab.unittest.plugins.diagnosticrecord.DiagnosticRecord | matlab.unittest.TestResult