Test Results Parser

0.6.1 · active · verified Wed Apr 15

The `test-results-parser` Python library provides functionalities to parse test result files, primarily JUnit XML. It offers two main parsing functions: `parse_junit_xml` for JUnit XML files and `parse_raw_upload` for raw test result uploads. This library is largely written in Rust with Python bindings, focusing on efficient test result processing for integration with platforms like Codecov. The current version is 0.6.1, and its release cadence appears irregular.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a JUnit XML file using `testing_result_parsers.parse_junit_xml`. It creates a dummy XML file, parses it, and then prints the name, outcome, and duration of each test run. The `parse_junit_xml` function returns a list of `Testrun` objects.

import testing_result_parsers
import os

# Create a dummy JUnit XML file for demonstration
dummy_junit_xml_content = '''
<testsuites>
  <testsuite name="my_suite" tests="2" failures="1" errors="0" skipped="0" time="1.5">
    <testcase classname="my_module.my_class" name="test_success" time="1.0" />
    <testcase classname="my_module.my_class" name="test_failure" time="0.5">
      <failure message="Assertion failed: 1 != 2">Traceback details...</failure>
    </testcase>
  </testsuite>
</testsuites>
'''

file_path = "dummy_junit.xml"
with open(file_path, "w") as f:
    f.write(dummy_junit_xml_content)

# Parse the JUnit XML file
test_runs = testing_result_parsers.parse_junit_xml(file_path)

for run in test_runs:
    print(f"Test Name: {run.name}, Outcome: {run.outcome}, Duration: {run.duration}")

# Clean up the dummy file
os.remove(file_path)

view raw JSON →