tags:

views:

41

answers:

1

Hello, I use the Ant API for creating tasks programmatically, but I have not yet found the class that create JUnit report task. in short, I want the equivalent of the code below using the Ant API:

<junitreport todir="..">
<fileset dir="..">
<include name="TEST-*.xml" />
</Fileset>
<report format="frames" todir=".." />
</Junitreport>

Thanks for your help.

+1  A: 

All task definitions are declared in ant.jar!org\apache\tools\ant\taskdefs\defaults.properties

Here is the JUnit-related ones:

junit=org.apache.tools.ant.taskdefs.optional.junit.JUnitTask
junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator

Here is corresponding Java code may look something like this:

FileSet fs = new FileSet();
fs.setDir(new File(".."));
fs.createInclude().setName("TEST-*.xml");

XMLResultAggregator aggregator = new XMLResultAggregator();
aggregator.addFileSet(fs);
AggregateTransformer transformer = aggregator.createReport();
transformer.setFormat(Format.FRAMES);
transformer.setTodir(new File("..");
Eugene Kuleshov
Thanks, I'll try it.Hope this solves my problem.