com.sun.javatest.lib
Class MultiStatus

java.lang.Object
  extended by com.sun.javatest.lib.MultiStatus

public class MultiStatus
extends java.lang.Object

When executing multiple test cases in the same test class, it is usually easier for each test case to return a Status object representing whether that individual test case passed or failed. However, combining those individual Status objects into one Status object to represent the overall Status of the tests executed can be difficult. This test library is designed to solve the problem of generating an aggregate or overall Status from multiple Status objects. The static method overallStatus is designed to take an array of Status objects from individual test cases and generate a Status object that correctly reflects the overall status of all the individual the test cases executed.

The rule for how MultiStatus calculates the overall Status of an array of Status objects is based on the following precedence:

If any of the test cases return a Status.FAILED, then the overall status is Status.FAILED.
If all test cases return Status.PASSED, then the overall status is Status.PASSED.
If at least one test case returns either a null Status or some other Status, the overall status is Status.FAILED.

For an example of how to use this library see the UmbrellaTest library or the JCK test case: tests/api/java_lang/Double/SerializeTests.html.


Constructor Summary
MultiStatus()
          Create a MultiStatus object to accumulate individual Status objects.
MultiStatus(java.io.PrintWriter out)
          Create a MultiStatus object to accumulate individual Status objects.
 
Method Summary
 void add(java.lang.String testID, Status status)
          Add another test result into the set for consideration.
 Status getStatus()
          Get the aggregate outcome of all the outcomes passed to "add".
 int getTestCount()
          Get the number of individual test results that have been added.
static Status overallStatus(java.lang.String[] testIDs, Status[] status)
          Generates a Status object that reflects an array of Status objects.
static Status overallStatus(java.lang.String[] testIDs, Status[] status, java.io.PrintWriter out)
          Generates a Status object that reflects an array of Status objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiStatus

public MultiStatus()
Create a MultiStatus object to accumulate individual Status objects.


MultiStatus

public MultiStatus(java.io.PrintWriter out)
Create a MultiStatus object to accumulate individual Status objects.

Parameters:
out - A stream to which the report the outcome of the tests. If the stream is null, no reporting is done.
Method Detail

getTestCount

public int getTestCount()
Get the number of individual test results that have been added.

Returns:
the number of individual results that have been added.

add

public void add(java.lang.String testID,
                Status status)
Add another test result into the set for consideration.

Parameters:
testID - A name for this test case. Should not be null.
status - The outcome of this test case

getStatus

public Status getStatus()
Get the aggregate outcome of all the outcomes passed to "add".

Returns:
the aggregate outcome

overallStatus

public static Status overallStatus(java.lang.String[] testIDs,
                                   Status[] status,
                                   java.io.PrintWriter out)
Generates a Status object that reflects an array of Status objects. Uses the algorithm above to generate an overall status from an array of Status objects. This method prints out the individual Status values from each test case to the PrintWriter supplied. If the PrintWriter is null, no output is generated.

Parameters:
testIDs - an array of names used to identify the individual test cases.
status - an array of Status objects giving the outcomes of the individual test cases.
out - a PrintWriter that can be used to output the individual test case status values. If null, no output is generated.
Returns:
the aggregate status of the array of Status objects.

overallStatus

public static Status overallStatus(java.lang.String[] testIDs,
                                   Status[] status)
Generates a Status object that reflects an array of Status objects. Uses the algorithm above to generate an overall status from an array of Status objects. This method does not output any information

Parameters:
testIDs - an array of names used to identify the individual test cases.
status - an array of Status objects giving the outcomes of the individual test cases.
Returns:
overall status of the specified array of Status objects.


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.