org.schmant.task.junit4.suitereporter
Class JUnit4TestSuiteReporter

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.junit4.suitereporter.JUnit4TestSuiteReporter
All Implemented Interfaces:
JUnit4Reporter<JUnit4TestSuiteReporter>

public class JUnit4TestSuiteReporter
extends AbstractArgumentChecker
implements JUnit4Reporter<JUnit4TestSuiteReporter>

The JUnit4TestSuiteReporter is a JUnit4Reporter used for reporting results from several test suites. It saves the results from each test run in an XML file and when printReport() is called, it assembles the results, uses a JUnit4TestSuiteReportPrinter to format the report, and prints it to the build thread's Report (usually to standard out and err).

The files are stored in the target directory set with setTarget(Object). If no target is set, a new temporary directory is created for the output files.

The XML files are named [prefix][integer].xml. The default value for the prefix is DEFAULT_XML_FILE_PREFIX (another prefix can be set with setXmlFilePrefix(String)). The integer is an index number that starts with 1 and is incremented for each test suite run.

By default, a SimpleJUnit4TestSuiteReportPrinter is used to format the report. To use another implementation, set it with setReportFormatter(JUnit4TestSuiteReportPrinter).

Since:
0.6
Author:
Karl Gustafsson
Task_package:
org.junit.junit4

Constructor Summary
JUnit4TestSuiteReporter()
           
 
Method Summary
 Map<String,String> getJavaSystemProperties(List<String> testSuiteClasses)
          Get the Map of Java system properties that the RunListener will use to configure itself.
 String getRunListenerClassName()
          Get the fully qualified name of the RunListener class.
 void printReport()
          This method prints the report to the thread's current Report (which often means that the report ends up being printed to standard out and err).
 void printReport(Report r)
          Print the test suite report to the supplied Report.
 JUnit4TestSuiteReporter setReportFormatter(JUnit4TestSuiteReportPrinter f)
          Set the report formatter to be used by printReport().
 JUnit4TestSuiteReporter setTarget(Object o)
          Set the target directory where XML files will be created.
 JUnit4TestSuiteReporter setXmlFilePrefix(String s)
          Set the file prefix for the XML files.
 void validateConfiguration(Collection<String> errMsgs)
          Validate the configuration.
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnit4TestSuiteReporter

public JUnit4TestSuiteReporter()
Method Detail

setTarget

public JUnit4TestSuiteReporter setTarget(Object o)
Set the target directory where XML files will be created.

If no target is set, a new temporary directory will be created for the generated XML files.

Parameters:
o - The target directory. The argument is interpreted with InterpretAsFileStrategy.
Returns:
this.

setXmlFilePrefix

public JUnit4TestSuiteReporter setXmlFilePrefix(String s)
Set the file prefix for the XML files.

Parameters:
s - The file prefix.
Returns:
this.

setReportFormatter

public JUnit4TestSuiteReporter setReportFormatter(JUnit4TestSuiteReportPrinter f)
Set the report formatter to be used by printReport().

Parameters:
f - The report formatter.
Returns:
this.

getRunListenerClassName

public String getRunListenerClassName()
Description copied from interface: JUnit4Reporter
Get the fully qualified name of the RunListener class.

Specified by:
getRunListenerClassName in interface JUnit4Reporter<JUnit4TestSuiteReporter>
Returns:
The fully qualified class name.

validateConfiguration

public void validateConfiguration(Collection<String> errMsgs)
Description copied from interface: JUnit4Reporter
Validate the configuration. Add error messages to the supplied collection.

Specified by:
validateConfiguration in interface JUnit4Reporter<JUnit4TestSuiteReporter>
Parameters:
errMsgs - The collection to add error messages to.

getJavaSystemProperties

public Map<String,String> getJavaSystemProperties(List<String> testSuiteClasses)
Description copied from interface: JUnit4Reporter
Get the Map of Java system properties that the RunListener will use to configure itself. This method may return null if the RunListener does not use any properties.

Specified by:
getJavaSystemProperties in interface JUnit4Reporter<JUnit4TestSuiteReporter>
Parameters:
testSuiteClasses - A list of all test classes to run.
Returns:
The system properties.

printReport

public void printReport()
This method prints the report to the thread's current Report (which often means that the report ends up being printed to standard out and err).


printReport

public void printReport(Report r)
Print the test suite report to the supplied Report.

Parameters:
r - The Report to print the test suite report to.