Out of Box

UFT – ALM Octane Integration without CI Server

Micro Focus Unified Functional Testing (UFT), formerly known as QuickTest Professional (QTP), is software that provides functional and regression test automation for software applications and environments. It s an automated functional Testing tool that helps testers to execute automated tests in order to identify any errors, defects or gaps.

ALM Octane is a web-based application lifecycle management platform that enables teams to collaborate easily, manage the product delivery pipeline, and visualize the impact of changes. Manage quality and test management of complex application portfolios at enterprise scale, within a hybrid application development environment.It Offers visibility and traceability across the application development lifecycle.

ALM octane support and run UFT automated tests in two ways: s: via pipelines, or via the testing framework integration. In Both ways you need to setup a CI Server( Jenkins or Bamboo) which required efforts ,time and cost to maintain & manage the CI server.

This post will explain how we can sent/upload results to ALM octane by UFT without using CI server.

1.Pre-requisite Tool
2.Implementation approach
3.Architecture
4.Implementation code

Pre-requisite

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

1.ALM Octane (Reader should have some understanding of ALM Octane)

2.UFT Tool((Unified Functional Testing)

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 Steps

ALM octane exposes REST APIs to sent result to ALM octane .Which opens the gate to send the results in customized way ,moreover by using there APIs we can integrate other automation tools as well with ALM octane.To send test results to the ALM Octane by using APIs ,below are steps :

1.Authenticate and Sign In:

To get APIs access or to authenticate below are 2 APIs :

Content-Type headerapplication/json
URIhttps://<host>/authentication/sign_in
Supported HTTP methodsPOST
Payload for user credentialsProvide a JSON object with the credentials. Use this type of payload to work with the API as the site admin. {      “user”: “<username>”,      “password”: “<password>” }
Payload for API keys{      “client_id”: “<client_id>”,      “client_secret”: “<client_secret>” }
CookieUpon successful authentication, the LWSSO_COOKIE_KEY cookie is set in the response.
Status code200 – Successful authentication401 (Unauthorized) – Failed authentication

This resource sets the authentication cookies required for future requests.If you are using payload for API Keys then you need Client ID and Secret otherwise you can use ALM octane credentials .

2.Retrieve the Test Results payload(XSD schema)

Before pushing the test results, retrieve the XSD schema of the payload using below GET API:

GET 
https://hostname/api/shared_spaces/<space_id>/workspaces/<workspace_id>/test-results/xsd

Use the XSD schema to prepare and validate your payload before using it. You will use the payload to:

  • Send ALM Octane the test and test run entities that you want to create or update.
  • The ALM Octane entities to link to the tests and test runs. You can specify these links globally for all entities reported in the payload, or specifically per test or test run.

Note : you can fetch the space_id and workspace_id from the URL.

3.Prepare and Validate Test Results payload:

Store your automated test results in a valid XML file. Use one of the following formats:

An XML file using API requirements:

If you have more complex cases, prepare the XML file according to the ALM Octane test result API. 

XML Payload:

<?xml version='1.0' encoding='UTF-8'?>
<test_result>
  <product_area>
        <product_area_ref_id="1234"/>
  </product_area>
 <test_fields>
<test_field type="Framework" value="UFT"/>
<test_field type="testingtool" value="UFT"/>
</test_fields>
<test_runs>
<test_run name="Regression_TC01_Example_Test" duration="90" status="Pass" started="1586260937443">
<release name="ReleaseName"/>
<environment>
<taxonomy type="browser" value="firefox"/>
</environment>
<error type="error_message" message="Error message in case of failure"/>
</test_run>
</test_runs>
</test_result>

For more detail to get familiar with the payload XML and how it relates to entities in ALM Octane. For sample payloads, see Sample payloads.

Linking tests and test run to other entities in the payload:

To link to this ALM Octane entity / attribute from a test or test run…Use this ALM Octane entity name in REST:Use this element / attribute in the payload XML:
Releasereleaserelease or release_ref
Story or Featurestory or featurebacklog_items or backlog_item_ref
Application moduleproduct_areaproduct_areas or product_area_ref
Testtesttest_fields or test_field or test_field_ref
Environmenttaxonomy_nodeenvironment or taxonomy or taxonomy_ref
Automated runrun_automatedtest_runs or test_run

For Detailed information on XML elements see here .

Verify that the payload conforms to the XSD schema before pushing the test results.Verify the xml with XSD.

4.Push the Test Results

Set the Content-Type header field set to application/xml. Make sure that the XML payload containing the test results conform to the XSD schema as described above.

POST https://hostname/api/shared_spaces/<space_id>/workspaces/<workspace_id>/test-results

By default, errors that occur while pushing the test results are not ignored and the POST fails. To skip the errors, specify the skip-errors parameter:

POST https://hostname/api/shared_spaces/<space_id>/workspaces/<workspace_id>/test-results?skip-errors=true

API Response :

Sample Response: 
202 Accepted
 {
     "status": "queued",
     "id": 1232
 }

5.Check the status of Test Result

Use below APIs to see the status of test result pushed to ALM Octane

GET
 https://hostname/api/shared_spaces/<space_id>/workspaces/<workspace_id>/test-results/1232

 Sample Response:
 200 Ok
 {
     "until": "2020-04-24T08:25:57+0000",
     "status": "warning",
     "id": 1232
 }

To see the log of request use below API:

GET
https://hostname/api/shared_spaces/<space_id>/workspaces/<workspace_id>/test-results/1232/log

Sample response:
status: failed
until: 2016-05-18T08:33:53+0300
Build reference {server: uuid; build_type: junit-job; build_sid: 1} not resolved

Architecture

Implementation code

Below is the UFT code snippet to generate the xml payload for each test case:

 tc_xml_request_body = "<?xml version='1.0' encoding='UTF-8'?><test_result><product_areas><product_area_ref id="&chr(34)&oct_application_module_id&chr(34)&"/></product_areas><test_fields><test_field type="&chr(34)&"Framework"&chr(34)&" value="&chr(34)&"UFT"&chr(34)&"/><test_field type="&chr(34)&"Test_Type"&chr(34)&" value="&chr(34)&"Regression"&chr(34)&"/><test_field type="&chr(34)&"Testing_Tool_Type"&chr(34)&" value="&chr(34)&"UFT"&chr(34)&"/><test_field type="&chr(34)&"Test_Level"&chr(34)&" value="&chr(34)&"System Test"&chr(34)&"/></test_fields><test_runs><test_run name="&chr(34)&oct_test_name&chr(34)&" duration="&chr(34)&test_execution_duration&chr(34)&" status="&chr(34)&test_status&chr(34)&" started="&chr(34)&test_start&chr(34)&"><release name="&chr(34)&oct_release_name&chr(34)&"/><environment><taxonomy type="&chr(34)&"environment"&chr(34)&" value="&chr(34)&test_environment&chr(34)&"/></environment><error type="&chr(34)&"error_message"&chr(34)&" message="&chr(34)&test_case_error_msg&chr(34)&"/></test_run></test_runs></test_result>"

Where you need to pass input data oct_test_name,oct_application_module_id ,oct_release_name,test_execution_duration,test_error_msg,test_environment,test_start,test_status for each test and generate a xml payload file by FSO .

Below are VB code to hit the REST APIs using curl command

 '1.curl command for API Json authentication
 curl_command_api_json_authentication = "curl -X POST -H "&Chr(34)&"Content-Type: application/json"&Chr(34)&" -c cookies.txt -d "&Chr(34)&"{\"&chr(34)&"user\"&chr(34)&":\"&chr(34)&octane_user_name&"\"&chr(34)&",\"&chr(34)&"password\"&chr(34)&":\"&chr(34)&octane_user_password&"\"&chr(34)&"}"&chr(34)&" "&chr(34)&"https://hostanme/authentication/sign_in"&chr(34)    
 
 '2.curl command to push the results in octane
curl_command_to_upload_result = "curl -X POST -H "&Chr(34)&"Content-Type: application/xml"&Chr(34)&" -b cookies.txt --data @"&request_body_file_name&".xml "&chr(34)&"https://hostname/api/shared_spaces/"&share_space_id&"/workspaces/"&work_space_id&"/test-results/?skip-errors=true"&chr(34)&" > "&response_body_file_name

 Set objShell = CreateObject("WScript.Shell")

'Hitting curl command to login
 command_status = objShell.run("cmd /K CD "&current_working_dir&" & "&curl_command_api_json_authentication,0,false' CMD invisible run mode

'Hitting curl command to push result
 command_status = objShell.run("cmd /K CD "&current_working_dir&" & "&curl_command_to_upload_result,0,false) 

'Curl command to check the log
 curl_command_to_check_log = "curl -X GET -b cookies.txt "&chr(34)&"https://hostname/api/shared_spaces/"&share_space_id&"/workspaces/"&work_space_id&"/test-results/"&octane_request_ID&"/log"&chr(34)&" > "&response_body_file_name    
             

Where

octane_user_name and octane_user_password are the ALM octane credential.
share_space_id and work_space_id are ALM Octane ids which you can get from URL after login into ALM Octane.
request_body_file_name file name of xml payload created.
response_body_file_name file name of text file to store the API response.
current_working_dir is the dir path where request_body_file_name and response_body_file_name is located
octane_request_ID is the id which you can fetch from push result API.cookies.txt

cookies.txt is the text file where your saving the ALM octane cookies which is located under the current_working_dir path.

For any support and assistance, please contact us to help you in implementing this out of box integration.

References

https://admhelp.microfocus.com/octane/en/15.0.40/Online/Content/API/how_test-results.htm

https://admhelp.microfocus.com/octane/en/15.0.40/Online/Content/API/test-results.htm#Sample

https://admhelp.microfocus.com/octane/en/15.0.40/Online/Content/API/Authenticate.htm#JSON

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