3 import xml
.etree
.ElementTree
as ET
10 print("Usage: xunit-summary.py <path to xunit results (*.xml)>")
12 test_dir
= sys
.argv
[1]
15 def __init__(self
, name
, total
, passed
, failed
, skipped
, errors
, time
):
19 self
.failed
= failed
+ errors
20 self
.skipped
= skipped
26 for testfile
in glob
.glob(test_dir
+ "/*-xunit.xml"):
27 assemblies
= ET
.parse(testfile
).getroot()
28 for assembly
in assemblies
:
29 test_name
= assembly
.attrib
.get("name")
31 print("WARNING: %s has no tests!" % ntpath
.basename(testfile
))
33 tests
.append(TestResults(test_name
,
34 int(assembly
.attrib
["total"]),
35 int(assembly
.attrib
["passed"]),
36 int(assembly
.attrib
["failed"]),
37 int(assembly
.attrib
["skipped"]),
38 int(assembly
.attrib
["errors"]),
39 float(assembly
.attrib
["time"])))
42 tests
.sort(key
=lambda item
: item
.name
)
47 #if t.failed > 0: # uncomment to list only test suits with failures
48 print("{0:<60} Total:{1:<6} Failed:{2:<6} Time:{3} sec".format(t
.name
, t
.total
, t
.failed
, round(t
.time
, 1)))
52 print("Total test suites: %d" % len(tests
))
53 print("Total tests run: %d" % sum(x
.total
for x
in tests
))
54 print("Total tests passed: %d" % sum(x
.passed
for x
in tests
))
55 print("Total tests failed: %d" % sum(x
.failed
for x
in tests
))
56 print("Total tests skipped: %d" % sum(x
.skipped
for x
in tests
))
57 print("Total duration: %d min" % (sum(x
.time
for x
in tests
) / 60))