Main Content

matlab.unittest.TestResult Class

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

expand all

Name of the TestSuite element corresponding to this result, specified as a character vector.

Indicator if the test passed, specified as true or false. When the Passed property is true, 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 or false. 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 as true 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 a TestResult 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 first TestSuite 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

expand all

Version History

Introduced in R2013a

expand all