Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

junit-report

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

junit-report

Export your test suites and cases to JUnit report using decorators

  • 0.2.7
  • PyPI
  • Socket score

Maintainers
1

Junit-Report

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

  • Junit-Report

Installation

pip install junit-report

Usage

import pytest

from junit_report import JunitTestSuite, JunitTestCase, JunitFixtureTestCase

class TestSomeThing:

    @pytest.fixture
    @JunitFixtureTestCase()
    def my_fixture(self):
        # do stuff ..
        
        @JunitTestCase()
        def nested_case():
          pass
        
        yield nested_case
        
    @JunitTestCase()
    def my_first_test_case(self):
        pass
    
    @JunitTestCase()
    def my_second_test_case(self, name: str):
        raise ValueError(f"Invalid name {name}")
    
    @JunitTestSuite()
    def test_suite(self, my_fixture):
        my_fixture()
        self.my_first_test_case()
        self.my_second_test_case("John")

Output

<?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>
		</testcase>
	</testsuite>
</testsuites>

OS parameters used for configuration

VariableDescription
JUNIT_REPORT_DIRReports directory where the reports will be extracted. If it does not exist - create it.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc