Testery Docs
TesteryFeaturesPricingRelease Notes
  • Testery Documentation
  • Release Notes
  • Get Started
    • Getting Started Guide
      • Create a Testery Account
      • Configure Your Project
      • Run Your Tests
      • Configure Slack Alerts
      • Schedule Your Test Runs
      • Invite Your Team
      • Get More From Testery
  • Get to Know Testery
    • Dashboard
    • Test Runs
      • Test Selection Rules
    • Projects
    • Test Triggers
    • Environments
    • Alerts
    • Settings
    • Test Plans
    • Test Stacks
      • Python
      • Node.js 16 End of Life
      • Default Chrome Version Change
      • Python 3.8 End of Life
    • Deployments
    • System Variables
    • Tags
    • Screenshots
    • Uploading Test Artifacts to Testery
    • Setting Test Execution Priority
    • Setting the Number of Parallel Tests
  • Integrate with Testery
    • Built-In Integrations with Testery
      • Jira
      • Slack
    • CI/CD Integration Guides
      • Azure Devops Pipelines
      • Set Up CircleCI to Run Testery Tests
      • Jenkins
      • GitHub Actions
      • Octopus Deploy
      • TugboatQA
    • Testery CLI
    • Testery REST API
      • Testery REST API Resources
    • Microsoft Teams
  • Framework-specific Guidance
    • Supported Testing Frameworks
    • Cypress
      • Updating Cypress Tests to Output in JUnit XML Format
    • Playwright
      • Update Playwright Tests to Output in JUnit XML Format for Import Into Testery
    • PyTest
      • Update Pytest to Generate JUnit XML for Import into Testery
    • TestNG
      • Updating TestNG Tests to Output in JUnit XML Format
  • How-To
    • Enable or Disable Automatic Rerunning of Tests
    • Run Cypress Tests without Connecting Repository
    • How to Store Sensitive Data Like Username and Password For a Cypress Test
    • Connect to a Private npm Repository
    • Running Scripts Before the Tests
    • Upload Test Run for Analysis
  • MISC
    • Troubleshooting Steps
  • Fixing Tests
    • Fix Common Selenium Exceptions
      • Fix a ChromeDriver Version Exception
      • Fix a NoSuchElement Exception
      • Fix a TimeoutException
      • Fix an ElementNotVisibleException
      • Fix a StaleElementReferenceException
      • Fix a WebDriverException
      • Fix an InvalidArgumentException
      • Fix a NoSuchWindowException
      • Fix an UnhandledAlertException
      • Fix an InvalidSelectorException
Powered by GitBook
On this page
  • Step 1: Install the pytest-xdist Plugin
  • Step 2: Update Your Pytest Configuration
  • Step 3: Run Your Pytest Tests
  • Step 4: Upload Your Test Results to Testery

Was this helpful?

  1. Framework-specific Guidance
  2. PyTest

Update Pytest to Generate JUnit XML for Import into Testery

Step 1: Install the pytest-xdist Plugin

To generate JUnit XML reports for your Pytest tests, you'll need to install the pytest-xdist plugin. This plugin extends Pytest's functionality and provides the JUnit XML report generation feature.

Open your project's terminal and run the following command to install the plugin:

pip install pytest-xdist

Step 2: Update Your Pytest Configuration

Now that you have the pytest-xdist plugin installed, you need to update your Pytest configuration to use it.

  1. Create a Pytest configuration file, if you don't already have one. The configuration file should be named pytest.ini or pyproject.toml (for newer Pytest versions).

  2. Add the following configuration to enable the JUnit XML report generation:

    For pytest.ini:

    [pytest]
    junit_family = xunit2
    junit_suite_name = Your_Test_Suite_Name
    junit_logging = all
    junit_log_passing_tests = True
    junit_log_truncate = True

    Replace Your_Test_Suite_Name with an appropriate name for your test suite.

    For pyproject.toml:

    [tool.pytest.ini_options]
    junit_family = 'xunit2'
    junit_suite_name = 'Your_Test_Suite_Name'
    junit_logging = 'all'
    junit_log_passing_tests = true
    junit_log_truncate = true

    Again, replace Your_Test_Suite_Name as needed.

Step 3: Run Your Pytest Tests

With your Pytest configuration updated, you can now run your tests as usual. Pytest will automatically use the JUnit XML reporter to generate XML reports.

To run your tests, use the following command:

pytest

After running the tests, you should see JUnit XML files generated in your project directory.

Step 4: Upload Your Test Results to Testery

The final step is to upload the generated JUnit XML files to Testery for further analysis. You can use the Testery CLI to achieve this. Ensure you have the Testery CLI installed:

pip install testery

Once installed, you can use the following command to upload your test results to Testery:

testery upload-results \
  --environment develop \
  --project Your_Project_Name \
  --file junit.xml

Replace Your_Project_Name with your specific project name and adjust the --file option to point to the location of your JUnit XML files generated by Pytest.

This step will make your Pytest test results accessible within Testery, allowing you to monitor and analyze them efficiently.

PreviousPyTestNextTestNG

Last updated 1 year ago

Was this helpful?