Result of running test suite
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.
TestResult arrays are created and returned by the test runner, and are of the same size as the suite which was run.
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.
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:
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.
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:
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.
The name of the TestSuite object for the result.
The Name property is a string that holds the name of the test corresponding to this result.
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.
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);
Add the matlab.unittest.TestSuite class to the current import list.
Result display method provides a summary of the results
suite = TestSuite.fromClass(?SomeTestClass) results = run(suite)
results = matlab.unittest.TestResult Test Suite Summary: 12 Passed, 4 Failed, 0 Not Run To Completion. 5.5091 seconds testing time.
Rerun only the failed tests.
failedTests = suite([results.Failed]); failedResults = run(failedTests)
failedResults = matlab.unittest.TestResult Test Suite Summary: 0 Passed, 4 Failed, 0 Not Run To Completion. 1.2894 seconds testing time.
Make the fix and rerun results.
newResults = run(failedTests)
newResults = matlab.unittest.TestResult Test Suite Summary: 4 Passed, 0 Failed, 0 Not Run To Completion. 1.1607 seconds testing time.