Thanks for the pointer. I found, however, that using doLast will only work so
long as all the tests pass. With some help from Luke Daley I got this working
by implementing a task listener:
task integrationTest(type: Exec) {
commandLine 'casperjs', 'test', '.',
"--xunit=$testResultsDir/TEST-casper-suite.xml", '--ignore-ssl-errors=yes'
workingDir = 'src/test/casper'
gradle.addListener(new TaskExecutionListener() {
void beforeExecute(Task task) {}
void afterExecute(Task task, TaskState taskState) {
if (task.name == 'integrationTest') {
def reporter = new co.freeside.gradle.CasperTestReport()
reporter.testResultsDir = task.project.testResultsDir
reporter.testReportDir = task.project.testReportDir
reporter.generateReport()
}
}
})
}
As you can see I also had to implement my own TestReport class as the
`DefaultTestReport` throws NPE as Casper doesn't generate timing information in
its XML. Right now this means that if any Casper XML files are around when the
regular `test` task runs then its own reporting will fail. I'm not sure if
there's a way to override the `TestReporter` implementation that gradle's
`test` task uses by default.
In an ideal world I should also get the Casper tests defined as a sourceSet, I
guess.
--
Rob Fletcher
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Tuesday, 5 June 2012 at 00:40, TheKaptain wrote:
> Not sure if this is encouraged or not, but it works :)
>
> task testSite(type: Exec) {
> commandLine 'casperjs', 'test', 'src/test/casper',
> "--xunit=$testResultsDir/casper-suite.xml"
> doLast{
> def reporter = new
> org.gradle.api.internal.tasks.testing.junit.report.DefaultTestReport()
> reporter.testResultsDir = file('path to result files from casper')
> reporter.testReportDir = file('path to where you want the reports
> written')
> reporter.generateReport()
> }
> }
>
>
> --
> View this message in context:
> http://gradle.1045684.n5.nabble.com/Generating-test-reports-from-non-JUnit-based-tests-tp5709848p5709857.html
> Sent from the gradle-user mailing list archive at Nabble.com
> (http://Nabble.com).
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email