matlab.unittest.diagnostics.DisplayDiagnostic class

Package: matlab.unittest.diagnostics
Superclasses: matlab.unittest.diagnostics.Diagnostic

Diagnostic using a value's displayed output

Description

The DisplayDiagnostic class provides a diagnostic result that uses a value’s displayed output. This output is the same text displayed using the display function. When the diagnostic information is accessible through a variable in the current workspace, the DisplayDiagnostic class is a means to provide quick diagnostic information.

Construction

DisplayDiagnostic(diagValue) creates a new DisplayDiagnostic instance.

Input Arguments

diagValue

The value that the Diagnostic uses to generate diagnostic information.

The resulting diagnostic information is equivalent to displaying this value at the MATLAB® command prompt. The result is packaged for consumption by the testing framework, which may or may not display the information at the command prompt.

Properties

Value

The value that the Diagnostic uses to generate diagnostic information, specified in the diagValue input argument. This property is read-only.

Inherited Properties

DiagnosticText

The DiagnosticText property provides the means by which the actual diagnostic information is communicated to consumers of diagnostics, such as testing frameworks. The property is a character vector that is defined during evaluation of the diagnose method.

Methods

Inherited Methods

diagnoseExecute diagnostic action
joinJoin multiple diagnostics into a single array

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

Examples

collapse all

Create a test case for interactive testing.

import matlab.unittest.TestCase
import matlab.unittest.constraints.IsEqualTo
import matlab.unittest.diagnostics.DisplayDiagnostic

testCase = TestCase.forInteractiveUse;

Use a DisplayDiagnostic to display diagnostic information upon test failure.

testCase.verifyThat(1, IsEqualTo(2), DisplayDiagnostic(inputParser))
Verification failed.

----------------
Test Diagnostic:
----------------
      inputParser with properties:
    
           FunctionName: ''
          CaseSensitive: 0
          KeepUnmatched: 0
        PartialMatching: 1
           StructExpand: 1
             Parameters: {1x0 cell}
                Results: [1x1 struct]
              Unmatched: [1x1 struct]
          UsingDefaults: {1x0 cell}

---------------------
Framework Diagnostic:
---------------------
IsEqualTo failed.
--> NumericComparator failed.
    --> The numeric values are not equal using "isequaln".
    --> Failure table:
                Actual    Expected    Error    RelativeError
                ______    ________    _____    _____________
            
                1         2           -1       -0.5         

Actual double:
         1
Expected double:
         2

In the test diagnostic section of the output, the output from inputParser object is the same as MATLAB displays at the command prompt.

Introduced in R2013a