It would be good to have GWT unit tests output results in a format
compatible with the junitreport Ant task. This is an xml format that is not
only supported by the junitreport task but by most continuous integration
build systems (e.g. Hudson) and by various XSL stylesheets to create unit
test reports. Attached is a Java class, GWTTestRunner, that provides this
output format.
An example of how to invoke this class from a Gant build file:
target(runClientTests: 'Run client unit tests') {
depends(compileClientTests);
ant.delete(dir: clientUnitTestReportDir, quiet: true);
ant.mkdir(dir: clientUnitTestReportDir);
ant.java(classname: 'com.foo.test.GWTTestRunner',
classpath: clientTestClasspath,
resultproperty: 'junitClientFailure',
fork: true) {
ant.arg(line: "--todir $clientUnitTestReportDir");
ant.arg(value: 'com.foo.test.AllTests');
if (osType == OSType.mac) {
ant.jvmarg(value: '-XstartOnFirstThread');
}
ant.jvmarg(value: '-Xmx1024m');
ant.jvmarg(value: '-d32');
ant.sysproperty(key: 'pia.home', value:
ant.project.properties.'pia.home');
ant.sysproperty(key: 'user.dir', value: userClientTestOutDir);
ant.sysproperty(key: 'gwt.args', value: "-out $userClientTestOutDir");
}
ant.junitreport(todir: clientUnitTestReportDir) {
ant.fileset(dir: clientUnitTestReportDir, includes: '*.xml');
ant.report(format: 'frames', todir: clientUnitTestReportDir);
}
if (ant.project.properties.'junitClientFailure' != '0') {
ant.fail('Failed client unit tests');
}
else {
ant.echo('Client unit tests PASSED');
}
}
This example fires off the class using the java task but a proper Ant task
could easily be created.
Originally reported on Google Code with ID 4076
Reported by
baron.roberts
on 2009-09-25 04:24:04