Skip to content

Commit cf71ee4

Browse files
committed
build.gradle: moved fail on test fail into finalizer task
1 parent dd8cac7 commit cf71ee4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,13 @@ task buildAndRunTests(type: TestLanguages, dependsOn: buildLanguages) {
212212
report(format: 'frames', todir: "$buildDir/junitreport")
213213
}
214214
ant.echo("JUnit report placed into $buildDir/junitreport/index.html")
215+
}
216+
}
215217

216-
// evaluate junit result and fail on error
218+
task failOnTestError() {
219+
description 'evaluate junit result and fail on error'
220+
doLast {
221+
217222
def junitResult = new XmlSlurper().parse(file('TESTS-TestSuites.xml'))
218223
def failures = junitResult.'**'.findAll { it.name() == 'failure' }
219224
def errors = junitResult.'**'.findAll { it.name() == 'errors' }
@@ -223,8 +228,9 @@ task buildAndRunTests(type: TestLanguages, dependsOn: buildLanguages) {
223228
throw new GradleException(amount + " JUnit tests failed. Check the test report for details.")
224229
}
225230
}
226-
}
227231

232+
}
233+
buildAndRunTests.configure { finalizedBy failOnTestError }
228234
check.dependsOn buildAndRunTests
229235

230236
task packageLanguages(type: Zip, dependsOn: buildLanguages) {

0 commit comments

Comments
 (0)