gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.52k stars 374 forks source link

JunitReport compatible unit test runner #4077

Open dankurka opened 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 4076

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.

Reported by baron.roberts on 2009-09-25 04:24:04


dankurka commented 9 years ago

Reported by jlabanca@google.com on 2009-12-15 21:10:15

dankurka commented 9 years ago

Reported by dankurka@google.com on 2013-05-26 21:47:53