Created
April 3, 2012 19:37
-
-
Save cburgmer/2295010 to your computer and use it in GitHub Desktop.
Using Gradle & ANT to get JUnit XML results (e.g. from Jasmine) in HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations { | |
jasmineXmlToHtml | |
} | |
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 { | |
convertJasmineXmlToHtml(resultsDir) | |
} | |
} | |
def convertJasmineXmlToHtml(resultsDir) { | |
targetDir = new File(resultsDir, 'html') | |
ant.taskdef( | |
name: 'junitreport', | |
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator', | |
classpath: configurations.jasmineXmlToHtml.asPath | |
) | |
ant.junitreport(todir: resultsDir) { | |
fileset(dir: resultsDir, includes: 'TEST-*.xml') | |
report(todir: targetDir, format: "frames") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<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> | |
</head> | |
<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 | |
jasmine.getEnv().execute(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment