Consider adding a diagnostic in your qualification method call. For instance, here's an example that checks that the sin.m file is NOT a file with the extension .m on the MATLAB search path. Since exist('sin.m', 'file') should return 2 since that is a file with the extension .m on the path, this test will fail. When it does, the function handle I've specified as a diagnostic will be executed. >> testCase = matlab.unittest.TestCase.forInteractiveUse;
>> verifyNotEqual(testCase, exist('sin.m', 'file'), 2, ...
@() fprintf('The sin.m file is located at %s.\n', which('sin.m')))
The result that is displayed in the Command Window is (I manually replaced my matlabroot by $MATLABROOT when I copied and pasted):
Interactive verification failed.
----------------
Test Diagnostic:
----------------
The sin.m file is located at $MATLABROOT\toolbox\matlab\elfun\sin.m.
---------------------
Framework Diagnostic:
---------------------
verifyNotEqual failed.
--> The values are equal using "isequaln".
Actual double:
2
Prohibited double:
2
If you want to display a message stored as a string or a char vector, or run a function handle, you can just specify the string, char vector, or function handle directly in your call like I did.
If you want to perform other types of diagnostics the link in the first sentence of my message includes a link to several diagnostic classes. You can instantiate one of those classes and pass the resulting object into the qualification method, just like I did with the function handle. For an example see the documentation for matlab.unittest.diagnostics.FigureDiagnostics. You could even build your own diagnostic class, specific for your application, by subclassing matlab.unittest.diagnostics.Diagnostic as shown in the example on its documentation page.
Best Answer