In your working folder, create the file ExampleTest.m
containing
the following test class.
The verifyEqual
qualification in testOne
causes
a test failure. The qualifications in testOne
and testTwo
include
an instance of a matlab.unittest.diagnostics.StringDiagnostic
.
At the command prompt, create a test suite from the ExampleTest
class.
Create a test runner that displays output to the command
window.
Create a TAPPlugin
that explicitly
specifies that its output should go to the file, MyTapOutput.tap
.
Add the plugin to the TestRunner
and
run the suite.
Running ExampleTest
================================================================================
Verification failed in ExampleTest/testOne.
----------------
Test Diagnostic:
----------------
Testing 5==4
---------------------
Framework Diagnostic:
---------------------
verifyEqual failed.
--> The values are not equal using "isequaln".
--> Failure table:
Actual Expected Error RelativeError
______ ________ _____ _____________
5 4 1 0.25
Actual double:
5
Expected double:
4
------------------
Stack Information:
------------------
In C:\work\ExampleTest.m (ExampleTest.testOne) at 4
================================================================================
...
Done ExampleTest
__________
Failure Summary:
Name Failed Incomplete Reason(s)
==================================================================
ExampleTest/testOne X Failed by verification.
Only the test failures produce output to the screen. By default,
TestRunner.withTextOutput
uses a
DiagnosticsOutputPlugin
to display output on the
screen.
Observe contents in the file created by the plugin.
1..3
not ok 1 - ExampleTest/testOne
# ================================================================================
# Verification failed in ExampleTest/testOne.
#
# ----------------
# Test Diagnostic:
# ----------------
# Testing 5==4
#
# ---------------------
# Framework Diagnostic:
# ---------------------
# verifyEqual failed.
# --> The values are not equal using "isequaln".
# --> Failure table:
# Actual Expected Error RelativeError
# ______ ________ _____ _____________
#
# 5 4 1 0.25
#
# Actual double:
# 5
# Expected double:
# 4
#
# ------------------
# Stack Information:
# ------------------
# In C:\work\ExampleTest.m (ExampleTest.testOne) at 4
# ================================================================================
#
ok 2 - ExampleTest/testTwo
ok 3 - ExampleTest/testThree