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
Name
— Name of TestSuite
element
character vector
Name of the TestSuite
element corresponding to this
result, specified as a character vector.
Passed
— Indicator if test passed
true
| false
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.
Failed
— Indicator if test failed
true
| false
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.
Incomplete
— Indicator if test did not run to completion
true
| false
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.
Duration
— Time spent running test
double
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.
Details
— Additional information about test
structure
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
Public Methods
assertSuccess | Assert test session ran without failure |
generateDOCXReport | Generate DOCX test report from test results |
generateHTMLReport | Generate HTML test report from test results |
generatePDFReport | Generate PDF test report from test results |
table | Convert TimeResult array to table |
Version History
Introduced in R2013aR2022a: Generate DOCX, HTML, and PDF reports after test execution
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.
R2020a: Assert that test session ran with no failure
The matlab.unittest.TestResult
class has a new method
assertSuccess
that lets you assert that no failing conditions were
encountered during a test session.
R2020a: Add custom details to TestResult
objects
When you create a custom plugin, you can add data to the Details
property of TestResult
objects. To append a field to the
Details
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.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)