TestNG
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 example-testng repository.
To use the plugin in your project you'll first have to add the Testery Gradle plugin to your build.gradle
file:
Then configure the plugin file in your build.gradle
file:
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:
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):
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.
For more details on uploading artifacts using the Testery CLI see upload your JAR file to Testery using the Testery CLI.
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
Last updated