Last active
August 29, 2015 13:55
-
-
Save airborn/8695259 to your computer and use it in GitHub Desktop.
Counting tests in JUnit report files
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
def path = args[0] | |
def regexp = /^Tests run: (\d+), Failures: (\d+), Errors: (\d+), Skipped: (\d+),/ | |
def results = [:].withDefault { 0 } | |
new File(path).eachFileMatch ~/.*\.txt/, { File file -> | |
file.eachLine { String line -> | |
def matcher = line =~ regexp; | |
matcher.each { pattern, tests, failures, errors, skipped -> | |
results['tests'] += tests.toInteger() | |
results['failures'] += failures.toInteger() | |
results['errors'] += errors.toInteger() | |
results['skipped'] += skipped.toInteger() | |
} | |
} | |
} | |
println results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment