Diagnostic using string
The StringDiagnostic class provides a diagnostic result using a string. When the diagnostic information is known at the time of construction, the StringDiagnostic is a means to provide quick diagnostic information.
When using matlab.unittest qualifications, a string can be directly supplied as a test diagnostic. In this case, the testing framework automatically creates a StringDiagnostic object.
StringDiagnostic(diagString) creates a new StringDiagnostic instance.
The string used by the Diagnostic to generate diagnostic information.
The DiagnosticResult property provides the means by which the actual diagnostic information is communicated to consumers of diagnostics, such as testing frameworks. The property is a string that is defined during evaluation of the diagnose method.
|diagnose||Execute diagnostic action|
|join||Join multiple diagnostics into a single array|
Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB® documentation.
import matlab.unittest.constraints.IsEqualTo; import matlab.unittest.diagnostics.StringDiagnostic; % Create a TestCase for interactive use testCase = matlab.unittest.TestCase; % Implicitly create a StringDiagnostic upon failuree testCase.verifyThat(1, IsEqualTo(2), ... 'actual was supposed to be equal to expected' ); % Provide a StringDiagnostic directly testCase.verifyThat(1, IsEqualTo(2), ... StringDiagnostic('actual was supposed to be equal to expected') );