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
  • Getting started
  • If using Gradle...
  • If using Maven...
  • Run your tests in Testery
  • Running TestNG tests on Testery

Was this helpful?

  1. Framework-specific Guidance

TestNG

PreviousUpdate Pytest to Generate JUnit XML for Import into TesteryNextUpdating TestNG Tests to Output in JUnit XML Format

Last updated 1 year ago

Was this helpful?

Getting started

There's a few things you should know when getting started running your tests using the TestNG framework on Testery. Since Java is a compiled language, Testery cannot pull your tests directly from your repository. You will need to upload a JAR file to Testery.

If using Gradle...

To see an example project using our Gradle plugin with TestNG you can look at our repository.

To use the plugin in your project you'll first have to add the Testery Gradle plugin to your build.gradle file:

plugins {
    id 'io.testery' version '1.3'
}

Then configure the plugin file in your build.gradle file:

testery {
    apiToken = System.getenv("TESTERY_API_TOKEN") // required
    projectKey = "my-testery-project-key" // required
    buildId = System.getenv("BUILD_ID") // required
    commitHash = System.getenv("GIT_COMMIT") // optional
    branch = System.getenv("GIT_BRANCH") // optional
}

Depending on your CI and environment, you might have to pull your apiToken buildId commitHash and branch from different variables.

You'll most likely have to configure an environment variable with your API token. The API token can be found in Testery on the Settings --> Integrations tab.

Once that is configured you can run this command: ./gradlew uploadBuildToTestery

If using Maven...

Create a fat JAR file

Testery will need a JAR file named testery.jar that contains all your test code and any dependencies that the tests depend on. It may be easiest to package up all source code, test code and all dependencies in one fat JAR file.

Add the following to your POM.xml file:

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.1.1</version>

				<configuration>
					<descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					</descriptorRefs>
					<descriptors>
						<descriptor>src/main/assembly/assembly.xml</descriptor>
					</descriptors>
				</configuration>

				<executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
  </plugin>

You will also need to create this assembly.xml file (replacing the path in your POM.xml file to the correct location in your project):

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>fat-tests</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>test</scope>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <directory>${project.build.directory}/test-classes</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>**/*.class</include>
            </includes>
            <useDefaultExcludes>true</useDefaultExcludes>
        </fileSet>
    </fileSets>
</assembly>

Now run this command: mvn clean compile test-compile assembly:single

Rename your JAR file to testery.jar before uploading to Testery.

Upload your testery.jar file to Testery

At this point you should have a fat JAR file named testery.jar that contains all your test code and required dependencies. Before uploading your JAR file to Testery make sure you have a project created in Testery to upload the JAR file to.

To upload your JAR using Testery CLI run this:

testery upload-build-artifacts --token {api-token} --project-key {project-key} --build-id {build-id} --path {directory_path}/testery.jar

The API token can be found in Testery on the Settings --> Integrations tab.

Run your tests in Testery

Now that you've uploaded your JAR to Testery make sure your project settings are correct. Especially testing framework field (should be TestNG) and the Java package field. Once that those set you can run your tests. Go to the Test Runs tab and select New Test Run. At a minimum, select your project and build along with any other options you want and click Run Test

Running TestNG tests on Testery

There are a few things to note when running your tests on Testery.

  • Ignored tests will now show up in Testery

  • Testery does not currently support TestNG suites (although this is coming soon)

  • Testery handles parallelization of tests so any parallel parameters in your tests will be ignored

For more details on uploading artifacts using the Testery CLI see .

example-testng
upload your JAR file to Testery using the Testery CLI