Commit 8d9985ae authored by norvell's avatar norvell
Browse files

Merge branch 'basop-ci/add-pytest-result-to-mld-report' into 'main'

[BASOP CI] Update scripts/parse_mld_xml.py to include pytest result

See merge request !1597
parents 0c4264e0 0cdd9904
Loading
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -28,13 +28,14 @@ if __name__ == "__main__":
    tree = ElementTree.parse(xml_report)

    testsuite = tree.find(".//testsuite")
    print(
        f"Found testsuite with {testsuite.get('tests')} tests and {testsuite.get('failures')} failures."
    )


    testcases = tree.findall(".//testcase")
    
    results_unsorted = {}
    passes = 0
    failures = 0
    errors = 0

    for testcase in testcases:
        if testcase.find(".//skipped") is None:
@@ -51,14 +52,29 @@ if __name__ == "__main__":
                p.get("name"): p.get("value")
                for p in testcase.findall(".//property")
            }

            if testcase.find('failure') is not None:
                testresult = 'FAIL'
                failures = failures + 1
            elif testcase.find('error') is not None:
                testresult = 'ERROR'
                errors = errors + 1
            else:
                testresult = 'PASS'
                passes = passes + 1

            properties_values = [str(properties_found.get(p)) for p in PROPERTIES]
            outline = ";".join([fulltestname] + properties_values) + "\n"
            outline = ";".join([fulltestname,testresult] + properties_values) + "\n"
            results_unsorted[fulltestname] = outline

    results_sorted = dict(sorted(results_unsorted.items()))

    with open(csv_file, "w") as outfile:
        headerline = ";".join(["testcase"] + PROPERTIES) + "\n"
        headerline = ";".join(["testcase","Result"] + PROPERTIES) + "\n"
        outfile.write(headerline)
        for test in results_sorted:
            outfile.write(results_sorted[test])

    print(
        f"Parsed testsuite with {passes+failures+errors} tests: {passes} passes, {failures} failures and {errors} errors."
    )