-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_coverage.py
More file actions
40 lines (33 loc) · 1.38 KB
/
verify_coverage.py
File metadata and controls
40 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import xml.etree.ElementTree as ET
def check():
xml_file = 'backend/target/site/jacoco/jacoco.xml'
tree = ET.parse(xml_file)
root = tree.getroot()
total_missed = 0
total_covered = 0
for counter in root.findall('counter'):
if counter.get('type') == 'LINE':
total_missed = int(counter.get('missed'))
total_covered = int(counter.get('covered'))
if total_covered + total_missed > 0:
coverage = (total_covered / (total_covered + total_missed)) * 100
print("Overall Backend Line Coverage: {:.2f}%".format(coverage))
else:
print("No line coverage data found in root counters")
print("\nClasses below 80%:")
for package in root.findall('package'):
pname = package.get('name').replace('/', '.')
for cls in package.findall('class'):
cname = cls.get('name').replace('/', '.')
if not cname.startswith('ch.goodone'): continue
line_counter = cls.find("counter[@type='LINE']")
if line_counter is not None:
m = int(line_counter.get('missed'))
c = int(line_counter.get('covered'))
if m + c > 0:
pct = (c / (m + c)) * 100
if pct < 80:
print("{}: {:.2f}%".format(cname, pct))
if __name__ == "__main__":
check()