matlab.unittest.TestResult - Result of running test suite - MATLAB (original) (raw)
Namespace: matlab.unittest
Result of running test suite
Description
The matlab.unittest.TestResult
class holds the information describing the result of running a test suite using the matlab.unittest
framework. The results include information describing whether the test passed, failed, or ran to completion, as well as the duration of each test.
Creation
TestResult
arrays are created and returned by the test runner. The number of objects in a TestResult
array matches the number of tests run in the suite.
Properties
Name of the TestSuite element corresponding to this result, specified as a character vector.
Indicator if the test passed, specified as true
orfalse
. When the Passed
property istrue
, then the test completed as expected without any failure. When it is false
, then the test did not run to completion, encountered a failure condition, or both.
Indicator if the test failed, specified as true
orfalse
. A true
value indicates some form of test failure. When Failed
is false
, then no failing conditions were encountered. A failing result can occur with a failure condition either in a test or in setting up and tearing down test fixtures. Failures can occur due to:
- Verification failures
- Assertion failures
- Uncaught exceptions
Fatal assertions are also failing conditions, but in the event of a fatal assertion failure, the entire framework aborts, and a TestResult
object is never produced.
Indicator if the test did not run to completion, specified astrue
or false
. A true
value indicates a test did not run to completion. When it is false
, then no conditions were encountered that prevented the test from completing. In other words,false
indicates there were no stack disruptions out of the running test content. An incomplete result can occur with a stack disruption in either a test or when setting up and tearing down test fixtures. Incomplete tests can occur due to:
- Assertion failures
- Tests filtered through assumption
- Uncaught exceptions
Fatal assertions are also conditions that prevent the completion of tests, but in the event of a fatal assertion failure, the entire framework aborts, and aTestResult
object is never produced.
Time spent running the test, including time for setting up and tearing down any test fixtures, specified as a double scalar.
Fixture setup time is accounted for in the duration of the firstTestSuite
element that uses the fixture. Fixture teardown time is accounted for in the duration of the TestSuite
element that uses the fixture.
The total run time for a suite of tests exceeds the sum of the durations for all the elements of the suite because the Duration
property does not include all the overhead of the TestRunner
object, nor any of the time consumed by test runner plugins.
Additional information about the test, specified as a scalar structure. The type of information depends on the configuration of the TestRunner
and its plugins. For example, the DiagnosticsRecordingPlugin uses this property to include diagnostic information it encounters during the test.
Methods
Version History
Introduced in R2013a
The matlab.unittest.TestResult
class has three new methods that enable you to generate various test reports from test results. You can run your tests and collect the test results, and then generate test reports from part or all of your results:
- To generate a DOCX report from the test results, use the
generateDOCXReport
method. - To generate an HTML report from the test results, use the
generateHTMLReport
method. - To generate a PDF report from the test results, use the
generatePDFReport
method.
The matlab.unittest.TestResult
class has a new methodassertSuccess
that lets you assert that no failing conditions were encountered during a test session.
When you create a custom plugin, you can add data to the Details
property of TestResult
objects. To append a field to theDetails
structure, use the append method of the matlab.unittest.plugins.plugindata.ResultDetails
class. For more information, see Write Plugin to Add Data to Test Results.