Page tree
Skip to end of metadata
Go to start of metadata

Watch Video


Introduction

QMetry Test Management for JIRA now allows users to import automation test results into JIRA.

Users can directly import their automation test result (JSON/XML/Zip) files using a REST API as soon as the automation test gets executed which would create a new test run in JIRA with all associated Test Cases; and results as executed in your automation test.

Certain automation attributes are used to check whether the Test Cases covered in automation testing already exist in JIRA.

If the Test Cases are already present in JIRA, then they are simply associated with the newly created test run and their test run results are updated with results of automation. For every new build, it re-uses the existing Test Cases in JIRA and evades creation of duplicate scenarios/steps respectively.

If the Test Cases are not found in JIRA, then they are added as new ones with their test results.

Note: The add-on user i.e. QMetry Test Management for JIRA, needs to have the following permissions to import automation results into QMetry Test Management for JIRA:

  • Browse Projects
  • Create issue
  • Edit issue
  • Transition Issues
  • Create Attachments

Supported Frameworks and Languages

The following automation frameworks are supported for importing results into QMetry Test Management for JIRA:

  • Cucumber
  • TestNG
  • JUnit
  • HP UFT
  • QAS

For reporting, you can use any of the above with Selenium or Appium.

All the languages supported by these frameworks are supported by QMetry Test Management for JIRA. Maven plugin only supports Cucumber + Java; REST API can be used for the rest.


Quick Reference Table

FrameworkSupported File/FormatsLanguages Supported
CucumberJSONJava, Ruby, Javascript, PHP, Python
TestNGXMLJava
JUnitXMLJava
QASzip containing JSON filesJava
SeleniumBased on reporting framework used as above
AppiumBased on reporting framework used as above


Where to find the Automation API?

  1. Go to QMetry > Automation API.
  2. Automation API screen opens with Project list, Link to generate API Key, REST API tab, and Maven tab.

Generating API Key

The API Key is unique to –

  • a particular user and project (for Server edition)
  • a particular user, project and client (for Cloud edition)


Steps

  1. Select the project the automation test results of which you want to import into JIRA.
  2. Click on the Generate link to generate the API Key.


The key is generated and displayed on the screen.


If you want to regenerate the API key for any reason, click the icon adjacent to the current API Key.

Import using API Key

You can use either of the following to import the automation results into JIRA:

  1. REST API
  2. Maven

Use the generated API Key in the REST API or in Maven dependency as per your project integration.

REST API

If REST API is integrated in the automation process, then the CI process will upload the automation test results using the REST API as soon as the automation test completes. The URL mentioned on the Automation API screen is used in CI for uploading the results. The maximum file size allowed to upload are 1) JSON file: 500 MB  2) XML and ZIP: 100 MB.


REQUEST PARAMETERS

Refer to the Request Parameters described on the screen to parameterize your REST API accordingly.

Note: zip file must contain files of the format given in the 'format' param.


ParameterTypeRequiredDescription
filemultipart fileYesYour result file to be uploaded. Supported file extensions: .json, .xml and .zip (zip file must contain files of the format given in the 'format' param).
apiKeystringYesYour API Key. API Key is unique for a specific user in a single project. The result will be imported for the project associated with the given API Key.
formatstringYesFormat of result file to be imported. Supported formats:
cucumber/json testng/xml junit/xml qas/json hpuft/xml
testRunNamestringNoName of the test run to be created. Default value: Test Run
platformstringNoName of Platform on which test run to be executed.
labelsstringNoComma separated names of Labels to be added to the test run.
versionsstringNoComma separated names of versions to be added to the test run.
componentsstringNoComma separated names of Components to be added to the test run.
sprintstringNoName of Sprint to be added to the test run.
commentstringNoComment to be added to the test run.


Code Snippet


LanguageCode Snippet

 cURL

curl -X POST -H "Content-Type: multipart/form-data" -F "file=@{file object}" -F "testRunName=TestRun" -F "apiKey=d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593" -F "format=cucumber/json" "/rest/qtm/latest/automation/importresults?os_username={username}&os_password={password}"
Java
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data");
RequestBody body = RequestBody.create(mediaType, "Content-Disposition: form-data; name=\"file\"; filename=\"{File object}\"Content-Type: false;Content-Disposition: form-data; name=\"testRunName\"TestRun;Content-Disposition: form-data; name=\"apiKey\"d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593;Content-Disposition: form-data; name=\"format\"cucumber/json");
Request request = new Request.Builder()
  .url("/rest/qtm/latest/automation/importresults?os_username={username}&os_password={password}")
  .post(body)
  .addHeader("content-type", "multipart/form-data")
  .build();

Response response = client.newCall(request).execute();
Ruby
require 'uri'
require 'net/http'

url = URI("/rest/qtm/latest/automation/importresults?os_username={username}&os_password={password}")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["content-type"] = 'multipart/form-data'
request.body = "Content-Disposition: form-data; name=\"file\"; filename=\"{file object}\";Content-Type: false;Content-Disposition: form-data; name=\"testRunName\"TestRun;Content-Disposition: form-data; name=\"apiKey\"d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593;Content-Disposition: form-data; name=\"format\"cucumber/json"

response = http.request(request)
puts response.read_body

JavaScript

var data = new FormData();
data.append("file", {"0":{}}); //Your file
data.append("testRunName", "TestRun");
data.append("apiKey", "d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593");
data.append("format", "cucumber/json");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "/rest/qtm/latest/automation/importresults?os_username={username}&os_password={password}");

xhr.send(data);
PHP
<?php
$request = new HttpRequest();
$request->setUrl('/rest/qtm/latest/automation/importresults');
$request->setMethod(HTTP_METH_POST);

$request->setQueryData(array(
  'os_username' => '{username}',
  'os_password' => '{password}'
));

$request->setHeaders(array(
  'content-type' => 'multipart/form-data'
));

$request->setBody('
Content-Disposition: form-data; name="file"; filename="{file object}"
Content-Type: false


Content-Disposition: form-data; name="testRunName"

TestRun
Content-Disposition: form-data; name="apiKey"

d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593
Content-Disposition: form-data; name="format"

cucumber/json');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}


Python
import requests

url = "/rest/qtm/latest/automation/importresults"

querystring = {"os_username":"{username}","os_password":"{password}"}

payload = "Content-Disposition: form-data; name=\"file\"; filename=\"{file object}\"Content-Type: false;Content-Disposition: form-data; name=\"testRunName\"TestRun;Content-Disposition: form-data; name=\"apiKey\"d4eb0762503dd75d0370f6249c27c74da9ade248b9bc8727ffd8bb06a325b593;Content-Disposition: form-data; name=\"format\"cucumber/json"
headers = {
    'content-type': "multipart/form-data"
}

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text)



Responses


ResponseDescription

Status 200 

Returned if results file is uploaded successfully. The import process might take a while and you would be notified (by email or checking the status of the created test run) once the process completed.

Example

{

    "testRunURL": "http://#######/browse/PROJ-1",
    "testRunKey": "PROJ-1"

}


Status 400
 

                                  

Returned if import fails

Example

{

    "errorMessage": "Invalid file format."

}


When you call the REST API, the import process starts running in the background and the test run status is displayed as "In Progress". Once the import process is complete, you will be notified by email and the test run status will be changed to its previous state.

The Automation Summary.txt file gets attached to the created test run on completion of the import process. The file contains Test Case details for the test run. It displays the following statistics:

  • New Test Cases Created 
  • Total Test Cases Re-Used

In case the automation test fails, the relevant error message is shown in the file as below.


Maven Dependency

If the automation project includes Cucumber + Java (with Maven) structure, then configure the Maven dependency in the project as described on the Automation API screen.

Open the pom.xml and add the configurations as described on the Automation API screen for Maven. Once the file is configured, the automation test results will get uploaded automatically whenever the user executes the automation project (e.g. using ‘mvn test’).

Step 1: Add the following to the <build> -> <plugins> block in your pom.xml:




Step 2: Add the following to the <dependencies> block in pom.xml:



Step 3: Add the following to the <repositories> block in pom.xml like:



Step 4: Finally add the following to your @CucumberOptions in the java file of your automation project for the 'plugin' option:



Viewing Execution Results in QMetry Test Management for JIRA

You can view the automation results of test cases through the execution screen.

Automation Attributes

Automation Attributes are used to identify Automated Test Cases uniquely. If you import another result having scenario or step, which has been imported previously, then existing Test Cases will be reused based on these attributes.


  • No labels