-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoverageReport.py
More file actions
27 lines (24 loc) · 1.19 KB
/
CoverageReport.py
File metadata and controls
27 lines (24 loc) · 1.19 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
import xml.etree.ElementTree as ET
import sys
def parse_jacoco_report(xml_path):
tree = ET.parse(xml_path)
root = tree.getroot()
all_covered = True
for package in root.findall('package'):
for class_tag in package.findall('class'):
name = class_tag.get('name')
for counter in class_tag.findall('counter'):
if counter.get('type') == 'INSTRUCTION':
missed = int(counter.get('missed'))
if missed > 0:
all_covered = False
source_name = class_tag.get('sourcefilename')
source_files = package.findall('sourcefile')
for sourcefile in source_files:
if sourcefile.get('name') == source_name:
missed_lines = [line.get('nr') for line in sourcefile.findall('line') if int(line.get('mi')) > 0]
print(f"{name} missed {missed} instructions on lines: {missed_lines}")
break
if all_covered:
print("100% COVERAGE ACHIEVED!")
parse_jacoco_report('build/reports/jacoco/test/jacocoTestReport.xml')