Skip to content

Commit 95103ea

Browse files
author
graeme
committed
re-worked runCompiledTests code, its still broken and but will have to stay that way for now. tests under grails-test execute as expected and produce the necessary reports
git-svn-id: https://svn.codehaus.org/grails/trunk@4145 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent edb6fa5 commit 95103ea

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

scripts/TestApp.groovy

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,45 @@ task ('default': "Run a Grails applications unit tests") {
5151
testDir = "${basedir}/target/test-reports"
5252

5353
task(testApp:"The test app implementation task") {
54-
//runCompiledTests()
54+
5555
Ant.mkdir(dir:testDir)
5656
Ant.mkdir(dir:"${testDir}/html")
5757
Ant.mkdir(dir:"${testDir}/plain")
5858

59+
//runCompiledTests()
5960
runGrailsTests()
61+
produceReports()
6062
}
6163

6264
task(runCompiledTests:"Runs the tests located under src/test which are compiled then executed") {
6365
compileTests()
64-
Ant.junit(fork:true, forkmode:"once") {
65-
jvmarg(value:"-Xmx256M")
66-
67-
formatter(type:"xml")
68-
batchtest(todir:"${basedir}/target/test-reports") {
69-
fileset(dir:"${basedir}/target/test-classes", includes:"**/*Tests.class")
70-
}
66+
Ant.sequential {
67+
junit(fork:true, forkmode:"once", failureproperty:"grails.test.failures") {
68+
classpath(refid:"grails.classpath")
69+
jvmarg(value:"-Xmx256M")
70+
71+
formatter(type:"xml")
72+
batchtest(todir:testDir) {
73+
fileset(dir:"${basedir}/target/test-classes", includes:"**/*Tests.class")
74+
}
75+
}
7176
}
72-
Ant.junitreport(tofile:"${testDir}/TEST-results.xml") {
73-
fileset(dir:"${basedir}/target/test-reports") {
77+
def result = Ant.antProject.properties["grails.test.failures"]
78+
if(result == "true") {
79+
event("StatusFinal", ["Compiled tests failed"])
80+
exit(1)
81+
}
82+
event("StatusFinal", ["Compiled tests complete"])
83+
}
84+
85+
86+
task(produceReports:"Outputs aggregated xml and html reports") {
87+
Ant.junitreport {
88+
fileset(dir:testDir) {
7489
include(name:"TEST-*.xml")
75-
report(format:"frames", todir:"${basedir}/target/test-reports/html")
7690
}
77-
}
78-
event("StatusFinal", ["Compiled tests complete"])
91+
report(format:"frames", todir:"${basedir}/target/test-reports/html")
92+
}
7993
}
8094

8195
task(runGrailsTests:"Runs Grails' tests under the grails-test directory") {
@@ -155,16 +169,7 @@ task(runGrailsTests:"Runs Grails' tests under the grails-test directory") {
155169
}
156170
finally {
157171
interceptor?.destroy()
158-
}
159-
160-
Ant.junitreport {
161-
fileset(dir:testDir) {
162-
include(name:"TEST-*.xml")
163-
}
164-
report(format:"frames", todir:"${basedir}/target/test-reports/html")
165-
}
166-
167-
172+
}
168173
}
169174
catch(Throwable e) {
170175
event("StatusUpdate", [ "Error executing tests ${e.message}"])

0 commit comments

Comments
 (0)