Skip to content

Commit d8a36c3

Browse files
authored
Merge pull request #807 from IETS3/feature/failBuildOnTestFailure
build.gradle: added build fail on test failure
2 parents 99d7430 + 14ec5b7 commit d8a36c3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The project does _not_ follow Semantic Versioning and the changes are documented
1515

1616
### Added
1717

18+
- updated gradle build. Build will now fail in case tests were failing.
1819
- Enumerations can have an order by declaration, by literal or by value ascociated with the literal
1920

2021
## January 2024

build.gradle

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import de.itemis.mps.gradle.*
2-
2+
import groovy.xml.XmlSlurper
33
import java.time.LocalDate
44
import java.time.format.DateTimeFormatter
55
import java.time.format.FormatStyle
@@ -215,6 +215,24 @@ task buildAndRunTests(type: TestLanguages, dependsOn: buildLanguages) {
215215
}
216216
}
217217

218+
task failOnTestError() {
219+
description 'evaluate junit result and fail on error'
220+
doLast {
221+
222+
def juniXml = file('TESTS-TestSuites.xml')
223+
if(juniXml.exists()){
224+
def junitResult = new XmlSlurper().parse(juniXml)
225+
def failures = junitResult.'**'.findAll { it.name() == 'failure' }
226+
def errors = junitResult.'**'.findAll { it.name() == 'error' }
227+
228+
if (failures || errors) {
229+
def amount = failures.size() + errors.size()
230+
throw new GradleException(amount + " JUnit tests failed. Check the test report for details.")
231+
}
232+
}
233+
}
234+
}
235+
buildAndRunTests.configure { finalizedBy failOnTestError }
218236
check.dependsOn buildAndRunTests
219237

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

0 commit comments

Comments
 (0)