Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

matlab.unittest.TestResult class

Package: 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.

Construction

TestResult arrays are created and returned by the test runner, and are of the same size as the suite which was run.

Properties

Name

The name of the TestSuite object for the result.

The Name property is a character vector that holds the name of the test corresponding to this result.

Passed

Logical value showing if the test passed.

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 and/or encountered a failure condition.

Failed

Logical value showing if test failed.

A TRUE Failed property 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 the following:

  • Verification failures

  • Assertion failures

  • Uncaught MExceptions

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.

Incomplete

Logical value showing if test did not run to completion.

A TRUE Incomplete property 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, when FALSE 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 the following:

  • Assertion failures

  • Tests filtered through assumption

  • Uncaught MExceptions

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.

Duration

Time elapsed running test.

The Duration property indicates the amount of time taken to run a particular test, including the time taken setting up and tearing down any test fixtures.

Fixture setup time is accounted for in the duration of the first test suite array element that uses the fixture. Fixture teardown time is accounted for in the duration of the last test suite array 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.

Details

Data for test result.

The Details property contains additional information relevant to the test execution. 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.

Tips

  • Create a table from the TestResult object for access to table functionality such as sorting rows, displaying a summary, and writing the table to a file. For example,

    rt = table(results);

Was this topic helpful?