Programmatically Access Test Diagnostics
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 thewithDefaultPlugins
static method.Run tests using the
run
method of theTestSuite
orTestCase
class.Run performance tests using the
runperf
function or therun
method of theTimeExperiment
class.
After your tests run, you can access recorded diagnostics using the
DiagnosticRecord
field in the Details
property
of TestResult
objects. For example, if your
test results are stored in the variable results
, then
result(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
, and
selectLogged
methods of the DiagnosticRecord
class.
By default, the plugin records failing events and events logged at the
matlab.automation.Verbosity.Terse
level. To record passing
diagnostics or messages logged at higher verbosity levels, create an instance of
DiagnosticsRecordingPlugin
and add it to the test runner.
See Also
Classes
matlab.unittest.plugins.DiagnosticsRecordingPlugin
|matlab.unittest.plugins.diagnosticrecord.DiagnosticRecord
|matlab.unittest.TestResult