Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » optional » junit » [javadoc | source]
org.apache.tools.ant.taskdefs.optional.junit
public class: XMLResultAggregator [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.Task
         org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator

All Implemented Interfaces:
    XMLConstants, Cloneable

Aggregates all <junit> XML formatter testsuite data under a specific directory and transforms the results via XSLT. It is not particulary clean but should be helpful while I am thinking about another technique.

The main problem is due to the fact that a JVM can be forked for a testcase thus making it impossible to aggregate all testcases since the listener is (obviously) in the forked JVM. A solution could be to write a TestListener that will receive events from the TestRunner via sockets. This is IMHO the simplest way to do it to avoid this file hacking thing.

Field Summary
protected  Vector filesets    the list of all filesets, that should contains the xml to aggregate 
protected  String toFile    the name of the result file 
protected  File toDir    the directory to write the file to 
protected  Vector transformers     
public static final  String DEFAULT_DIR    The default directory: .. It is resolved from the project directory 
public static final  String DEFAULT_FILENAME    the default file name: TESTS-TestSuites.xml 
protected  int generatedId    the current generated id 
static final  String WARNING_IS_POSSIBLY_CORRUPTED    text checked for in tests, {@value} 
static final  String WARNING_INVALID_ROOT_ELEMENT    text checked for in tests, {@value} 
static final  String WARNING_EMPTY_FILE    text checked for in tests, {@value} 
Fields inherited from org.apache.tools.ant.Task:
target,  taskName,  taskType,  wrapper
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Method from org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator Summary:
addFileSet,   addTestSuite,   createDocument,   createReport,   execute,   getDestinationFile,   getFiles,   setTodir,   setTofile,   writeDOMTree
Methods from org.apache.tools.ant.Task:
bindToOwner,   execute,   getOwningTarget,   getRuntimeConfigurableWrapper,   getTaskName,   getTaskType,   getWrapper,   handleErrorFlush,   handleErrorOutput,   handleFlush,   handleInput,   handleOutput,   init,   isInvalid,   log,   log,   log,   log,   markInvalid,   maybeConfigure,   perform,   reconfigure,   setOwningTarget,   setRuntimeConfigurableWrapper,   setTaskName,   setTaskType
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator Detail:
 public  void addFileSet(FileSet fs) 
    Add a new fileset containing the XML results to aggregate
 protected  void addTestSuite(Element root,
    Element testsuite) 

    Add a new testsuite node to the document. The main difference is that it split the previous fully qualified name into a package and a name.

    For example: org.apache.Whatever will be split into org.apache and Whatever.

 protected Element createDocument() 

    Create a DOM tree. Has 'testsuites' as firstchild and aggregates all testsuite results that exists in the base directory.

 public AggregateTransformer createReport() 
    Generate a report based on the document created by the merge.
 public  void execute() throws BuildException 
    Aggregate all testsuites into a single document and write it to the specified directory and file.
 public File getDestinationFile() 
    Get the full destination file where to write the result. It is made of the todir and tofile attributes.
 protected File[] getFiles() 
    Get all .xml files in the fileset.
 public  void setTodir(File value) 
    Set the destination directory where the results should be written. If not set if will use #DEFAULT_DIR . When given a relative directory it will resolve it from the project directory.
 public  void setTofile(String value) 
    Set the name of the aggregegated results file. It must be relative from the todir attribute. If not set it will use #DEFAULT_FILENAME
 protected  void writeDOMTree(Document doc,
    File file) throws IOException 
    Write the DOM tree to a file.