The Artima Developer Community
Sponsored Link

Create an XML Reporter for Your Unit Tests
by Bill Venners
February 24, 2003

<<  Page 2 of 8  >>

Advertisement

Reporter Configuration and Disposal

In addition to the 11 event handler methods, interface Reporter declares two other methods, setConfiguration and dispose, shown in Figure 2. You must of course also implement these two methods in your custom Reporter.

Figure 2. Reporter's Configuration and Disposal Methods

org.suiterunner
Reporter
public interface Reporter
    Interface implemented by classes whose instances collect the results of a running suite of tests and presents those results in some way to the user.
Methods
public void dispose()
    Release any non-memory finite resources, such as file handles, held by this Reporter.
public void setConfiguration(java.util.Set configs)
    Configures this Reporter with a specified Set of configuration Characters.

The dispose method is called at the end of the Reporter's life, before it is discarded for garbage collection. If your custom reporter holds finite non-memory resources, such as file handles, database connections, or sockets, you should release these in your dispose method.

The setConfiguration method takes a Set of configuration constants that indicate which of the 11 possible events should actually be reported to the user. For example, a Reporter can be configured to report test failure events, but not test starting or test succeeded events. The valid contents of the Set passed to setConfiguration are defined as configuration Character constants in interface Reporter, as shown in Figure 3.

Figure 3. Reporter's Configuration Character Constants

org.suiterunner
Reporter
public interface Reporter
    Interface implemented by classes whose instances collect the results of a running suite of tests and presents those results in some way to the user.
Fields
public static final Character PRESENT_INFO_PROVIDED
    Configuration Character that indicates infoProvided method invocations should be presented to the user.
public static final Character PRESENT_RUN_ABORTED
    Configuration Character that indicates runAborted method invocations should be presented to the user.
public static final Character PRESENT_RUN_COMPLETED
    Configuration Character that indicates runCompleted method invocations should be presented to the user.
public static final Character PRESENT_RUN_STARTING
    Configuration Character that indicates runStarting method invocations should be presented to the user.
public static final Character PRESENT_RUN_STOPPED
    Configuration Character that indicates runComleted method invocations should be presented to the user.
public static final Character PRESENT_SUITE_ABORTED
    Configuration Character that indicates suiteAborted method invocations should be presented to the user.
public static final Character PRESENT_SUITE_COMPLETED
    Configuration Character that indicates suiteCompleted method invocations should be presented to the user.
public static final Character PRESENT_SUITE_STARTING
    Configuration Character that indicates suiteStarting method invocations should be presented to the user.
public static final Character PRESENT_TEST_FAILED
    Configuration Character that indicates testFailed method invocations should be presented to the user.
public static final Character PRESENT_TEST_STARTING
    Configuration Character that indicates testStarting method invocations should be presented to the user.
public static final Character PRESENT_TEST_SUCCEEDED
    Configuration Character that indicates testSucceeded method invocations should be presented to the user.

<<  Page 2 of 8  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us