Skip to main content
Skip table of contents

JUnit XML result

There are 2 approaches to importing JUnit XML Result files using the API:

This JUnit framework supports only Generic test cases. Test step details for other types will be excluded from the parsed results.

1. Import Test Result only

This approach allows you to quickly upload test results to AgileTest without needing to include extra metadata like test execution timestamps, environment details, or other specific execution parameters.

You can locate the endpoint at the POST /ds/test-executions/junit in the API document.

When you click on the 🔽 button, a dialog will appear. Here you can input your information for the test result file upload.

There are 2 main sections:

  • Parameters: fields that you define as key parameters required to make a successful API request. These parameters include:

Parameters

Type

Required

Description

projectKey

string

Key of the project where the test results will be imported.

milestoneId

integer

 

Milestone id to link to Test execution.

testExecutionKey

string

 

Test execution key to import test report.

testPlanKeys

array[string]

 

Test plan key to import test report.

If you specify a Test Plan, the tests will automatically be added to it if they are not already included.

testEnvironments

array[string]

 

A string containing a list of test environments separated by ",".

fixVersions

array[string]

 

A string containing a list of fixVersions separated by “,”.

revision

string

 

Revision to link to Test execution.

  • Request body: where you can input an XML file, which is a JUnit report that is going to be imported.

Test result example
CODE
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="com.shoppingapp.AddressTest" time="0.006" tests="9" errors="0" skipped="0" failures="0">
  <properties>
    <property name="gopherProxySet" value="false"/>
    <property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
    <property name="java.specification.version" value="11"/>
    <property name="sun.cpu.isalist" value=""/>
    <property name="sun.jnu.encoding" value="UTF-8"/>
    <property name="java.class.path" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/test-classes:/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/classes:/Users/thachnguyen/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar:/Users/thachnguyen/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:/Users/thachnguyen/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/thachnguyen/.m2/repository/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar:/Users/thachnguyen/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar:/Users/thachnguyen/.m2/repository/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar:/Users/thachnguyen/.m2/repository/org/mockito/mockito-core/3.12.4/mockito-core-3.12.4.jar:/Users/thachnguyen/.m2/repository/net/bytebuddy/byte-buddy/1.11.13/byte-buddy-1.11.13.jar:/Users/thachnguyen/.m2/repository/net/bytebuddy/byte-buddy-agent/1.11.13/byte-buddy-agent-1.11.13.jar:/Users/thachnguyen/.m2/repository/org/objenesis/objenesis/3.2/objenesis-3.2.jar:/Users/thachnguyen/.m2/repository/org/mockito/mockito-junit-jupiter/3.12.4/mockito-junit-jupiter-3.12.4.jar:/Users/thachnguyen/.m2/repository/org/slf4j/slf4j-simple/1.7.30/slf4j-simple-1.7.30.jar:/Users/thachnguyen/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:"/>
    <property name="java.vm.vendor" value="Homebrew"/>
    <property name="sun.arch.data.model" value="64"/>
    <property name="java.vendor.url" value="https://github.com/Homebrew/homebrew-core/issues"/>
    <property name="user.timezone" value=""/>
    <property name="java.vm.specification.version" value="11"/>
    <property name="os.name" value="Mac OS X"/>
    <property name="sun.java.launcher" value="SUN_STANDARD"/>
    <property name="user.country" value="VN"/>
    <property name="sun.boot.library.path" value="/opt/homebrew/Cellar/openjdk@11/11.0.21/libexec/openjdk.jdk/Contents/Home/lib"/>
    <property name="sun.java.command" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/surefire/surefirebooter3444332120704230486.jar /Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/surefire 2024-11-05T16-27-38_971-jvmRun1 surefire14941232156557041274tmp surefire_0651957426851720248tmp"/>
    <property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="jdk.debug" value="release"/>
    <property name="surefire.test.class.path" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/test-classes:/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/classes:/Users/thachnguyen/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar:/Users/thachnguyen/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:/Users/thachnguyen/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/Users/thachnguyen/.m2/repository/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar:/Users/thachnguyen/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar:/Users/thachnguyen/.m2/repository/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar:/Users/thachnguyen/.m2/repository/org/mockito/mockito-core/3.12.4/mockito-core-3.12.4.jar:/Users/thachnguyen/.m2/repository/net/bytebuddy/byte-buddy/1.11.13/byte-buddy-1.11.13.jar:/Users/thachnguyen/.m2/repository/net/bytebuddy/byte-buddy-agent/1.11.13/byte-buddy-agent-1.11.13.jar:/Users/thachnguyen/.m2/repository/org/objenesis/objenesis/3.2/objenesis-3.2.jar:/Users/thachnguyen/.m2/repository/org/mockito/mockito-junit-jupiter/3.12.4/mockito-junit-jupiter-3.12.4.jar:/Users/thachnguyen/.m2/repository/org/slf4j/slf4j-simple/1.7.30/slf4j-simple-1.7.30.jar:/Users/thachnguyen/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar:"/>
    <property name="sun.cpu.endian" value="little"/>
    <property name="user.home" value="/Users/thachnguyen"/>
    <property name="user.language" value="en"/>
    <property name="java.specification.vendor" value="Oracle Corporation"/>
    <property name="java.version.date" value="2023-10-17"/>
    <property name="java.home" value="/opt/homebrew/Cellar/openjdk@11/11.0.21/libexec/openjdk.jdk/Contents/Home"/>
    <property name="file.separator" value="/"/>
    <property name="basedir" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit"/>
    <property name="java.vm.compressedOopsMode" value="Zero based"/>
    <property name="line.separator" value="&#10;"/>
    <property name="java.specification.name" value="Java Platform API Specification"/>
    <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
    <property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/>
    <property name="surefire.real.class.path" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit/target/surefire/surefirebooter3444332120704230486.jar"/>
    <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
    <property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
    <property name="java.runtime.version" value="11.0.21+0"/>
    <property name="user.name" value="thachnguyen"/>
    <property name="path.separator" value=":"/>
    <property name="os.version" value="12.5"/>
    <property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
    <property name="file.encoding" value="UTF-8"/>
    <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
    <property name="java.vendor.version" value="Homebrew"/>
    <property name="localRepository" value="/Users/thachnguyen/.m2/repository"/>
    <property name="java.vendor.url.bug" value="https://github.com/Homebrew/homebrew-core/issues"/>
    <property name="java.io.tmpdir" value="/var/folders/f0/hxzh9_fx1zb29pdn334l6nr40000gn/T/"/>
    <property name="java.version" value="11.0.21"/>
    <property name="user.dir" value="/Users/thachnguyen/Work/autotest/agile-test-sample-projects/junit"/>
    <property name="os.arch" value="aarch64"/>
    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
    <property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/>
    <property name="sun.os.patch.level" value="unknown"/>
    <property name="java.library.path" value="/Users/thachnguyen/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
    <property name="java.vm.info" value="mixed mode"/>
    <property name="java.vendor" value="Homebrew"/>
    <property name="java.vm.version" value="11.0.21+0"/>
    <property name="java.specification.maintenance.version" value="2"/>
    <property name="sun.io.unicode.encoding" value="UnicodeBig"/>
    <property name="java.class.version" value="55.0"/>
    <property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
  </properties>
  <testcase name="testEqualsSameAddress" classname="com.shoppingapp.AddressTest" time="0.001"/>
  <testcase name="testHashCodeConsistency" classname="com.shoppingapp.AddressTest" time="0"/>
  <testcase name="testEqualsDifferentAddress" classname="com.shoppingapp.AddressTest" time="0.004"/>
  <testcase name="testGetFullAddress" classname="com.shoppingapp.AddressTest" time="0"/>
  <testcase name="testSetStreet" classname="com.shoppingapp.AddressTest" time="0.001"/>
  <testcase name="testSetCity" classname="com.shoppingapp.AddressTest" time="0"/>
  <testcase name="testToStringFormat" classname="com.shoppingapp.AddressTest" time="0"/>
  <testcase name="testSetZipCode" classname="com.shoppingapp.AddressTest" time="0"/>
  <testcase name="testSetState" classname="com.shoppingapp.AddressTest" time="0"/>
</testsuite>

Learn more about the JUnit testing framework.

Then, you will receive an output example

Output example
CODE
{
    "id": "321016",
    "key": "ATP-1856",
    "url": "https://company.atlassian.net/browse/ATP-1856"
}

In case you want to use the command line, file pipeline, and other tools instead of API docs, you can copy the curl and input the token to import test results.

CODE
curl -X 'POST' \
  'https://api.agiletest.app/ds/test-executions/junit?projectKey=ATP' \
  -H 'accept: application/json' \
  -H 'Authorization: JWT <token>' \
  -H 'Content-Type: application/xml' \
  --data-binary '@my-report.xml'

In that, <token> is the result from the Get Authenticated step.

2. Import Test Result with New Execution Details

This approach allows you to import JUnit XML test results while including additional execution details, such as timestamps, environment details, test execution keys, and other specific parameters related to the test executions.

You can locate the endpoint at the POST /ds/test-executions/junit/multipart in the API document.

For this request, it does not require any parameters. Instead, you need to submit two separate files:

  • A file containing the test results to import. This file resembles the test result files used in the Import Test Result only approach.

  • A file containing the test execution details. This file has some fields, and each of these fields serves a specific purpose in creating and organizing the test execution:

    • The fields object contains standard issue creation information, like what project it belongs to and what type of issue it is. It has 3 compulsory fields summary, project.id, and issuetype.id. Additionally, you can include other optional Jira fields, such as labels, priority, or any custom fields that your Jira instance uses.

    • The agileTestFields object contains Agile Test-specific information for linking the execution to milestones and test plans, both of which are optional.

Field

Group

Type

Required

Description

summary

fields

string

Summary of Test execution issue that will be created.

project.id

string

Project ID in which the Test execution will be created.

issuetype.id

string

The identifier specifying the type of issue to be created.

 

milestoneId

agileTestFields

integer

 

The identifier of the milestone that this test execution should be associated with.

testPlanKeys

array of string

 

An array of issue keys of Test plan that this test execution is related to.

testEnvironments

array of string

 

A string containing a list of test environments separated by ",".

fixVersions

array of string

 

A string containing a list of fixVersions separated by “,”.

revision

string

 

Revision to link to Test execution.

Test Execution detail example
CODE
{
  "fields": {
    "summary": "Regression test",
    "project": {
      "id": "17110"
    },
    "issuetype": {
      "id": "16396"
    }
  },
  "agileTestFields": {
    "milestoneId": 5555,
    "testPlanKeys": ["ATP-364", "ATP-362"]
  }
}

Make sure all details provided are accurate and relevant; otherwise, the request will fail. For example, if the issuetype.id you specify a value that does not exist in the project with ID 17110, the system will return an error with the corresponding error code 400.

Then, you will receive an output example

Output example
CODE
{
  "id": "321348",
  "key": "ATP-1859",
  "url": "https://company.atlassian.net/browse/ATP-1859"
}

In case you want to use the command line, file pipeline, and other tools instead of API docs, you can copy the curl and input the token to import test results.

CODE
curl -X 'POST' \
  'https://api.agiletest.app/ds/test-executions/behave/multipart' \
  -H 'accept: application/json' \
  -H 'Authorization: JWT <token>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'results=@my-report.xml;type=application/xml' \
  -F 'testExecution=@test-execution.json;type=application/json'

In that, <token> is the result from the Get Authenticated step.


Should you need any assistance or further AgileTest inquiries, contact our 24/7 Support Desk!

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.