Skip to main content

Export your test suites and cases to JUnit report using decorators

Project description


This Python package adds more control to your tests by decorating your functions and pytest fixtures and exporting them as JUnit xml.

Table of contents


pip install junit-report


import pytest

from junit_report import JunitTestSuite, JunitTestCase, JunitFixtureTestCase

class TestSomeThing:

    def my_fixture(self):
        # do stuff ..
        def nested_case():
        yield nested_case
    def my_first_test_case(self):
    def my_second_test_case(self, name: str):
        raise ValueError(f"Invalid name {name}")
    def test_suite(self, my_fixture):


<?xml version="1.0" ?>
<testsuites disabled="0" errors="0" failures="1" tests="4" time="0.000301361083984375">
	<testsuite disabled="0" errors="0" failures="1" name="TestSomeThing_test_suite" skipped="0" tests="4" time="0.000301361083984375">
		<testcase name="my_fixture" time="0.000163" classname="TestSomeThing" class="fixture"/>
		<testcase name="nested_case" time="0.000034" classname="module_name.test" class="function"/>
		<testcase name="my_first_test_case" time="0.000017" classname="TestSomeThing" class="function"/>
		<testcase name="my_second_test_case" time="0.000087" classname="TestSomeThing" class="function">
			<failure type="ValueError" message="Invalid name John">Traceback (most recent call last): ... ValueError: Invalid name John</failure>

OS parameters used for configuration

Variable Description
JUNIT_REPORT_DIR Reports directory where the reports will be extracted. If it does not exist - create it.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

junit-report-0.2.7.tar.gz (12.1 kB view hashes)

Uploaded source

Built Distribution

junit_report-0.2.7-py3-none-any.whl (14.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page