Skip to content

Instantly share code, notes, and snippets.

@airborn
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save airborn/8695259 to your computer and use it in GitHub Desktop.
Save airborn/8695259 to your computer and use it in GitHub Desktop.
Counting tests in JUnit report files
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