Update pipeline-netcore-runtime.yml
[mono-project.git] / netcore / xunit-summary.py
blobb6a6787649f53156bc0fcde7f3a47d4e879836fa
1 #!/usr/bin/env python3
3 import xml.etree.ElementTree as ET
4 import os
5 import glob
6 import ntpath
7 import sys
9 if len(sys.argv) < 1:
10 print("Usage: xunit-summary.py <path to xunit results (*.xml)>")
11 sys.exit(1)
12 test_dir = sys.argv [1]
14 class TestResults():
15 def __init__(self, name, total, passed, failed, skipped, errors, time):
16 self.name = name
17 self.total = total
18 self.passed = passed
19 self.failed = failed + errors
20 self.skipped = skipped
21 self.time = time
23 print("")
25 tests = []
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")
30 if test_name is None:
31 print("WARNING: %s has no tests!" % ntpath.basename(testfile))
32 continue
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"])))
41 # sort by name
42 tests.sort(key=lambda item: item.name)
44 print("")
45 print("=" * 105)
46 for t in tests:
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)))
49 print("=" * 105)
51 print("")
52 print("Total test suits: %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))
58 print("")