Ant: create JUnit report task programatically

I use the Ant API for software, but I have not yet found a class that creates a JUnit report task. In short, I want the code equivalent below using the Ant API:

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

Thank you for your help.

+2
source share
1 answer

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

Here are the related to JUnit:

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

Here the appropriate Java code might 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(".."); 
+5
source

All Articles