Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image Modified


Table of Contents

...

Gradle is an open-source build tool that provides flexibility, and performance through task parallelization. It Gradle is known in Java projects, as an alternative to Maven, but also supports other languages. Find out more about its features in  on Gradle's site. 

Integration with Xray is possible using Xray APIs, namelly namely the REST API for importing test results.

You can use this integration to upload test results to Xray, in one of the supported test reports/formats, so that you have visibility of your test results from your pipeline in Jira.

...

Our task will make use of several variables.

In Gradle, we can define some variables within the tasks themselves, and they will be instantiated during the configuration phase.

...

Examples

JUnit4

In this example, the tests are implemented using Java + JUnit 4.13.x.

...

To run the tests and import them to Xray we can run gradle Gradle as usual and add the name of the task we created earlier. 

...

In Xray, a Test Execution will be created accordingly.

JUnit5

In this example, the tests are implemented using Java + JUnit 5.8.x.

...

JUnit5 with additional information 

In this example, the tests are implemented using Java + JUnit 5.8.x.

...

Info

In this case, we'll use the enhanced capabilities that Xray provides for JUnit allowing you to provide additional information during the execution of the tests, including screenshots and otherothers; to do so, we'll use the xray-junit-extensions package.

...

To run the tests and import them to Xray we can run gradle Gradle as usual and add the name of the task we created earlier. 

...

In Xray, a Test Execution will be created accordingly.

TestNG

In this example, the tests are implemented using Java + TestNG 7.6.x.

...

TestNG with additional information 

In this example, the tests are implemented using Java + TestNG 7.6.x.

...

Info

In this case, we'll use the enhanced capabilities that Xray provides for TestNG allowing you to provide additional information during the execution of the tests, including screenshots and otherothers; to do so, we'll use the xray-testng-extensions package.

...

The following example shows a build.gradle file with a custom task named importTestNGResultsToXrayDC where we implement the logic to push the results to Xray. 

In this case, we won't be using the built-in test task; instead, we implement a custom one name named testngTest as we need to provide additional parameters to the XMLReporter class provided by TestNG that otherwise is not yet possible; this is what enables the feature of embedding additional attributes on the TestNG XML report that Xray can take advantage of.

...

To run the tests and import them to Xray we can run gradle Gradle as usual and add the name of the task we created earlier. 

...

  • To debug existing tasks, run your gradle Gradle command with "–stacktrace"
  • On the custom tasks that execute a command using exec, set ignoreExitValue = false

...