Out of Box

UFT integration with Xray-JIRA

UFT/QTP is one of most popular and industry approved tool for automation and JIRA is most popular tool agile project management , Now most of product developments follow agile methodology ,as Agile is an iterative approach to project management and software development that helps teams deliver value to their customers faster and with fewer headaches.It provides flexibility for frequent changes during software development .

Xray is JIRA plugin for test management just like ALM , we can have test plan ,test cases ,test execution ,test sets all similar to ALM. Though UFT provide integration with ALM but not with Xray-JIRA.

After executing test scripts in UFT we have to upload the results in JIRA manually which time ,effort and cost consuming activity.

This blog explain integration of Xray with UFT tool to import/upload the results to Xray- JIRA (a test management plugin for JIRA). It describes the implementation approach, features, architecture.

Pre-requisite tools

Below is the list of required tools which are used to perform the Xray to UFT integration.

1.JIRA with Xray (Reader should have some understanding of Xray-JIRA)

2.UFT

3.Curl – It command line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP or FILE). curl is powered by Libcurl. This tool is preferred for automation, since it is designed to work without user interaction.

Implementation Approach

Xray exposed REST APIS to upload the results in Xray in different format like, Cucumber, TestNG, NUnit, Robot Framework etc. Here we are using API Xray JSON results for uploading results through UFT. Xray given a JSON result format for Manual ,Automated and generic test type to import/upload the result into Xray JIRA.

We have below 3 Xray JSON result format to upload the result in Xray.

1.Automated Tests

2.Manual Tests

3.Generic Test

There is  below 2 places where test results can be uploaded in Xray.

1.New Test Execution

2.Existing Test Execution

API End Point : https://eteamproject.internal.ericsson.com/rest/api/2/issue/createmeta

API Request Type: POST

JSON Request Body:

  1. New Execution :
{
    "info" : {
        "summary" : "Execution of automated tests from UFT",
        "description" : "This execution is automatically created when importing execution “,
        "version" : "",
        "user" : "Mohd Nizam",
        "revision" : "",
        "startDate" : "2020-02-06T11:30:35+01:00",
        "finishDate" : "2020-02-06T11:35:35+01:00",
        "testPlanKey" : "DemoPlan-321",
        "testEnvironments": ["Chrome","Test"]
    },
    "tests" : [
         {
            "testKey": "DemoTest-326",
            "start": "2020-02-06T11:31:35+01:00",
            "finish": "2020-02-06T11:33:32+01:00",
            "comment": "Manual Test - Execution failed at #2 FAIL.",
            "status" : "FAIL",           
            "steps": [
                {
                    "status": "PASS",
                    "comment": "Test Step 1 - PASS"                   
                },
                {
                    "status": "FAIL",
                    "comment": "Test Step 2 - Failed Reason - An unexpected error message",
                    "evidences": [
                        {
                            "data": "(... base 64 encoded ...)",
                            "filename": "DemoTest-326_Fail_screenshot.jpg",
                            "contentType": "image/jpeg"
                        }
                    ]
                }
            ]
        }
    ]
}

2. Existing Test Execution

{
    "testExecutionKey": "DemoTestExecutionKey-1206",
    "tests" : [
         {
            "testKey”: "DemoTest-326",
            "start”: "2020-02-06T11:31:35+01:00",
            "finish”: "2020-02-06T11:33:32+01:00",
            "comment": "Manual Test - Execution failed at #2 FAIL.",
            "status": "FAIL",           
            "steps": [
                {
                    "status": "PASS",
                    "comment": "Test Step 1 - PASS"                   
                },
                {
                    "status": "FAIL",
                    "comment": "Test Step 2 - Failed Reason - An unexpected error message",
                    "evidences": [
                        {
                            "data": "(... base 64 encoded ...)",
                            "filename": "DemoTest-326_Fail_screenshot.jpg",
                            "contentType": "image/jpeg"
                        }
                    ]
                }
            ]
        }
    ]
}

Similarly, for Automated & Generic test type there is no steps defined in JIRA so for these test types above JSON request body is same except there will be no more steps[] node in the JSON request body.

In this implementation ,the approach is to use the REST APIS  provided by Xray to upload the results. Xray provides REST APIs to import/upload the results in different format like, Cucumber, TestNG, NUnit, Robot Framework etc. Here we are using API Xray JSON results for uploading results through UFT. Xray given a JSON result format for Manual ,Automated and generic test type to import/upload the result into Xray JIRA.

The concept is to write automation results executed by UFT into given JSON format dynamically at run time using the data given into Xray data sheet for each test case into a JSON file, then use this JSON file to execute the Xray REST API to upload the results.

UFT Framework execute test cases and generates the required Xray JSON Format data dynamically based on the data given in the Xray data sheet and save JSON data to a JSON file for each test case. Curl command hit/execute API with JSON file as input through CMD and save the response in a text file

For uploading an image, code converts image into Base 64 encoding string then using that base 64 encoded string in the APIs.  For mapping between Xray and UFT test cases we can use JIRA Test Key and TestCase ID.

Architecture

Key Features

  • Supports upload/attachment of screenshots for the All or Failed test steps for manual test type only.
  • Supports upload of results for Manual, Automated and Generic test type of JIRA.
  • Ability to create a New or to use Existing test execution in Xray.
  • Ability to add the tests to test plan.
  • Test step level reporting like step state(status), comment (actual result), Evidence (screenshot) for manual test type in Xray JIRA.
  • Test case level reporting like execution status, comment in Xray JIRA.

Challenges Faced

  1. As JIRA don’t provide integration of Xray with UFT so there is no help on google for Xray to UFT integration except for Xray REST APIs details.
  2. To implement and merged it with existing framework without affecting its functionality.
  3. Mapping of test cases and how to control the executions of test cases.
  4. How to convert an image into Base64 encoding string to upload the image in Xray by REST API using code.
  5. How to dynamically generate the request json for each test case result separately.
  6. How use JSON string as VB string to escape the double quotes.
  7. Parametrizing the json at run time as per setting defined in the Xray Setting sheet.
  8. Handing of test start and end date format: Conversion of local to UTC time and in JSON date time format given in API.
  9. How to execute the curl command in cmd window, making it invisible, fetching data from a curl command response and storing in a variable by code in UFT.
  10. JSON file UTF 8 encoding issue

Conclusion

In this document, we have seen the integration of Xray with UFT though Xray doesn’t provide any official & specific integration with UFT like we have with ALM but with the help of REST APIs we can implement. This will help in test management by reducing the time, effort and cost in manually maintaining the results in Xray JIRA.

This implementation supports all three-test type in Xray JIRA – Manual, Automated & Generic. The scope of this implementation is generic we can also use it in API Testing as well.

References:

https://confluence.xpand-it.com/display/public/XRAY/REST+API

Categories: Out of Box, UFT/QTP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s