Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Using Gradle & ANT to get JUnit XML results (e.g. from Jasmine) in HTML
configurations {
dependencies {
jasmineXmlToHtml 'org.apache.ant:ant-junit:1.8.2'
task jasmine(type: Exec) {
workingDir = 'src/test'
runnerFile = new File(workingDir, 'lib/phantomjs-testrunner.js')
specRunnerFile = 'file:///' + new File(workingDir, 'SpecRunner.html').absolutePath.replaceAll('\\\\', "/")
resultsDir = new File(buildDir, 'reports/jasmine')
commandLine = ['phantomjs', runnerFile, specRunnerFile]
doLast {
def convertJasmineXmlToHtml(resultsDir) {
targetDir = new File(resultsDir, 'html')
name: 'junitreport',
classname: '',
classpath: configurations.jasmineXmlToHtml.asPath
ant.junitreport(todir: resultsDir) {
fileset(dir: resultsDir, includes: 'TEST-*.xml')
report(todir: targetDir, format: "frames")
<!DOCTYPE html>
<title>Jasmine Spec Runner</title>
<link rel="stylesheet" type="text/css" href="../lib/jasmine-1.1.0/jasmine.css">
<script type="text/javascript" src="../lib/jasmine-1.1.0/jasmine.js"></script>
<script type="text/javascript" src="../lib/jasmine.junit_reporter.js"></script>
<script type="text/javascript">
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('../../build/reports/jasmine/', false)); // don't consolidate so that JUnitReport can pick up the XML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment