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
  • Prerequisites
  • Step 1: Add TestNG JUnit XML Listener
  • Step 2: Run Your TestNG Tests
  • Step 3: Upload Your Test Results to Testery

Was this helpful?

  1. Framework-specific Guidance
  2. TestNG

Updating TestNG Tests to Output in JUnit XML Format

In this article, we'll guide you through the process of updating your TestNG tests to output results in JUnit XML format and then uploading these results to Testery for further analysis and monitoring

Prerequisites

Before you begin, ensure you have the following prerequisites in place:

  1. TestNG Installed: You should have TestNG installed in your Java project. You can do this by adding the TestNG dependency to your project's build file, such as Maven or Gradle.

  2. Java: Make sure you have Java installed on your machine.

  3. A TestNG Test Suite: You should have a TestNG test suite already set up and running.

  4. Testery CLI: You will need the Testery CLI to upload your JUnit XML files to Testery. If you don't have it installed, you can do so using pip:

    pip install testery

Step 1: Add TestNG JUnit XML Listener

To generate JUnit XML reports for your TestNG tests, you'll need to add the org.testng.reporters.JUnitReportReporter listener to your TestNG suite. This listener automatically generates JUnit XML reports during test execution.

Open your TestNG suite XML file and add the following listener configuration:

xmlCopy code<suite name="Your_Test_Suite_Name">
    <listeners>
        <listener class-name="org.testng.reporters.JUnitReportReporter" />
    </listeners>
    <!-- Other suite configurations -->
    <test name="Your_Test">
        <!-- Test configurations -->
        <classes>
            <class name="com.example.YourTestClass" />
            <!-- Add more classes if needed -->
        </classes>
    </test>
    <!-- Add more tests if needed -->
</suite>

Replace Your_Test_Suite_Name with an appropriate name for your test suite and update the class names as needed.

Step 2: Run Your TestNG Tests

With the TestNG suite configured to use the JUnit XML listener, you can run your tests as usual. TestNG will automatically generate JUnit XML reports during test execution.

You can run your TestNG suite using your preferred build tool or directly from the command line. For example, using Maven:

mvn clean test

After running the tests, you should see JUnit XML files generated in the default output folder.

Step 3: 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-test-run \
  --environment-key develop \
  --project-key Your_Project_Name \
  --path target/surefire-reports/junitreports/*.xml

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

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

PreviousTestNGNextEnable or Disable Automatic Rerunning of Tests

Last updated 1 year ago

Was this helpful?