-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.gradle
More file actions
23 lines (22 loc) · 881 Bytes
/
Copy pathcoverage.gradle
File metadata and controls
23 lines (22 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) 2017 Gonzalo Müller Bravo.
// Licensed under the MIT License (MIT), see LICENSE.txt
ext.showRatios = {
final report = file(it)
if (report.exists()) {
double total = 0
final numberFormatter = new java.text.DecimalFormat('0.00')
final xml = new XmlSlurper(false, false, true)
xml.setFeature 'http://apache.org/xml/features/nonvalidating/load-external-dtd', false
logger.quiet '\n\tCoverage ratios:\n'
final counter = xml.parse(report).counter
counter.each {
final ratio = it.@covered.toDouble() / (it.@missed.toDouble() + it.@covered.toDouble())
total += ratio
final typeTitle = it.@type.toString()
.toLowerCase()
.capitalize()
logger.quiet "\t* $typeTitle = ${numberFormatter.format(ratio)}"
}
logger.quiet "\n\tAverage = ${numberFormatter.format(total / counter.size())}\n"
}
}