In a file in your current folder, create a class named ToFigure
that redirects the plugin output to a figure and displays it in a list box within the
figure. Define the Figure
and ListBox
properties
to represent the figure and the handle to the list box, respectively.
You must implement the print
method for any subclass of
OutputStream
. In this example, the method creates a new figure
(if necessary), formats the incoming text, and then adds it to the output stream.
In a methods
block with private
access,
implement a helper method named createFigure
that creates the figure
and the list box used by the plugin.
Save the ToFigure
class. Now, in your current folder, create a file
named ExampleTest.m
containing the following test class. The
verifyEqual
qualification in testOne
causes a
test failure. The verification in testTwo
passes. The test
corresponding to testThree
passes without producing an output.
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 DiagnosticsValidationPlugin
instance that
explicitly specifies that its output should go to a figure using the
ToFigure
output stream.
Add the plugin to the runner and run the tests.
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 Value:
5
Expected Value:
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.
In addition to the default text output being displayed on the screen, the
DiagnosticsValidationPlugin
output is directed to a docked
figure. The figure shows this text.
------------------------------
Validation of Test Diagnostic:
------------------------------
Testing 5==4
------------------------------
Validation of Test Diagnostic:
------------------------------
Testing 5==5
The DiagnosticsValidationPlugin
displays the diagnostic information
regardless of whether the tests encounter failure conditions.