Follow

Detailed Explanation on How to Execute QMetry Testcase using API with Sample Example

There are 6 steps run the QMetry Testcase using API. Please check below sequence API call to execute the testcase.

Step 1 : Get token using Authentication API.

Token :    a) For every user authentication QMetry assigns the authentication token which is valid for that session only.

              b) For every user session authentication token is different.

              c) Once the token gets expired (session expired) user needs to generate new token otherwise it will cause session expire error.

 

API : Authentication

URL - /rest/login

Method - POST

Request Header -   1. Accept : application/json

                            2. Content-Type : application/x-www-form-urlencoded

                            3. User-Agent : Blank or Some String (User Agent is a mandatory parameter from 6.6 onward, currently it can contain empty string.We recommend that you enter some values like "QMetry API" OR "Python Agent" in the User Agent parameter)

 

Request Body - username=<provide user name in url encoded format>&password=     <provide password in url encoded format>

Response -

{
"success": true,
"usertoken":
"E8FFYPXtYsVlNruyq7Ii"
}

-------------------------------------------------------------------------------------------------------------------------

Step 2 : Get the List of Execution Status ID.

Execution Statuses : Status usually refers to Testcase status. The default statuses are test runs are “Passed”, “Failed”, “Not Run”, “Blocked” or “Not Applicable”.

Execution Status ID varies project to project. It can be obtained from QMetry UI also. Please check below screenshot.

 

API :API to list execution Statuses

URL : rest/admin/execution/list

Method : POST

Request Header :a) Accept: application/json

                         b) scope: <domain.id>:<release.id>:<cycle.id>

                         c) usertoken: <usertoken>

                         d) Content-Type: application/json

Request Body : {roleID:<User role id>}

 

Response Body :

[
{
"execStatusManagementID":
<execution status id>,
"name": "<status name>",
"displayName": "<status name>",
"defaultRunName": "<default run
name>",
"isArchived": "<true if archived,
false is unarchived>",
"isMasterStatus": "true"
}
......
..
]
 
  • Please check below API to get RoleID :

API:API to list user roles

URL: /rest/admin/role/list

Method: POST

Request Header: a) Accept: application/json

         b) scope: <domain.id>:<release.id>:<cycle.id>

         c) usertoken: <usertoken>

         d) Content-Type: application/json

Request Body : {}

Response Body :

[
{
"roleID": <Role Id>,
"description": "<Role Description>",
"name": "<Role Name>",
"addLdapRole": <true if default active for
LDAP user & false if default inactive for LDAP
users>,
"isDefault": <,
"allowEditRecordData": <false if user do not
have right to change system settings & true if user
has right to change system settings>
},
......
...
]

--------------------------------------------------------------------------------------------------------------------

Step 3 : Get Drop Id using List Builds service

Drop - A drop is another term used by organizations for a build, often it refers to a combination of multiple software and/or hardware builds and/or configurations.

API : API to list all build

URL - rest/admin/drop/list

Method - POST

Request Header :  a) Accept: application/json

                         b) scope: <domain.id>:<release.id>:<cycle.id>

                         c) usertoken: <usertoken>

                         d) Content-Type: application/json

 

Request Body :  { }

 

Response Body :

[
{
"dropID": "<Build Id>",
"name": "<Name of the build>",
"Associatcycle": "<Name of the cycle
to which build is associated>",
"isArchieved": <false if unarchived,
true if archived>,
"assocReleaseName": "<name of the
release to which build is associated >",
"Defaultcycle": "<default build
cycle>",
"defaultReleaseName": "<default
release cycle"
},
.....
...
]
 
 
--------------------------------------------------------------------------------------
 
 

Step 4 :  Get TestSuite Run ID from QMetry UI.

Testsuite Run ID - Testsuite Run Id is a combination of Testsuite and platform. These ids are always same for the combination of Testsuite and Platform.

There are couple of way to fetch the Test suite run id :

  1. This can be fetch from QMetry UI, Testsuite Detail View – Linked Platform Grid – by enabling the hidden column “Testsuite Run id”.

 

     2. Test suite RunID can be fetched by calling “Get Testsuite Run Id’s using Testsuite Id” rest service. It will required Test suite id “TsID” which can be fetched by using “Get Testsuites” Rest Service

 

API : Get Testsuite Run Id's from Testsuite Id

URL : rest/execution/list

Method : Post

Request Header :    a) Accept: application/json

                             b) usertoken : <usertoken>

                             c) scope : default

                             d) Content-Type: application/json


Request Body :

{

"entityId": <Testsuite ID, Get it from calling API Get Testsuites : Field Name "tsID”>,

 "scope":"cycle"

}

 

Response :

{

                "data": [{

                                "Total": 1,

                                "name": "Chrome",

                                "platformID": 8896,

                                "tsRunID": 65992,

                                "tsID": 52237,

                                "isTestRun": false,

                                "plGroupName": "",

                                "isArchived": false,

                                "totalExecutionTime": 0,

                                "RemainingTime": 0,

                                "status_784": 0,

                                "status_783": 0,

                                "status_782": 0,

                                "status_781": 1,

                                "status_780": 0,

                                "status_785": 0,

                                "statusID": 781

                }, {

                                "Total": 1,

                                "name": "Windows",

                                "platformID": 8897,

                                "tsRunID": 65993,

                                "tsID": 52237,

                                "isTestRun": false,

                                "plGroupName": "",

                                "isArchived": false,

                                "totalExecutionTime": 0,

                                "RemainingTime": 0,

                                "status_784": 0,

                                "status_783": 0,

                                "status_782": 0,

                                "status_781": 1,

                                "status_780": 0,

                                "status_785": 0,

                                "statusID": 781

                }],

                " total": 2

}

 

  •  Below is the API to get Testsuite ID

 

API : Get list of all Testsuite under folder/Get details of Testsuite and its status

URL :  /rest/testsuites/list

Method : POST

Request Header : a) Accept: application/json

                        b) usertoken : <usertoken>

                        c) scope : default

                        d) Content-Type: application/json

 

Request Body :

{

            "scope": "cycle",

            "tsFolderID": < testsuite root folder id obtained from get - info or

            parent folder id > ,

            "page": < page number e.g.1 > ,

            "start": < starting record e.g.0 >

            "limit": < no of records per page e.g.50 >

}

 

 

Response :

 

{

            "data": [{

                        "tsID": < TestSuite ID > ,

                        "entityKey": "TestSuite Entity Key",

                        "associatedCycles": "TestSuite

                        Associated to the cycles ",

                        "tsFolderID": < TestSuite Parent

                        Folder Id > ,

                        "name": "<Name of TestSuite>",

                        "linkedTcCount": < Number of Testcase

                        Linked > ,

                        "linkedPlatform": < Number of

                        Platform Linked > ,

                        "attachmentCount": < Number of

                        Attachment Linked > ,

                        "createdDate": "<Created date and

                        time > ",

                        "createdBy": < User Id who created

                        the testsuite > ,

                        "createdByAlias": "<Alias name of

                        Success.

                        Returns the

                        following: Get list of all

                        testsuites under

                        the folder.

                        the creator > ",

                        "owner": < User Id of the Owner > ,

                        "ownerAlias": "<Alias name of the

                        owner > ",

                        "testSuiteState": < TestSuite State

                        id > ,

                        "testSuiteStateAlias": "<TestSuite

                        State Name > ",

                        "testsuiteStatus": "<TestSuite

                        Status ie.uncovered,

                        Passed,

                        Failed,

                        NotRun,

                        Blocked,

                        Not Applicable > ",

                        "StatusID": < TestSuite Status Id > ,

                        "folderPath": "<Folder Path of the

                        testsuite > ",

                        "Total": < Total Testcase runs > ,

                        "ExecutionTime": < Total Execution

                        Time > ,

                        "RemainingTime": < Total Remaining

                        Time > ,

                        "status_1717": < No of Testcase run

                        count based on Status > ,

                        "status_1716": < No of Testcase run

                        count based on Status > ,

                        "status_1719": < No of Testcase run

                        count based on Status > ,

                        "status_1718": < No of Testcase run

                        count based on Status > ,

                        "status_1720": < No of Testcase run

                        count based on Status > ,

                        "status_1721": < No of Testcase run

                        count based on Status >

                        .....

            }],

            "total": < No of TestSuites >

}

-----------------------------------------------------------------------------------------------------------------------------

Step 5 : Get Testcase Run Id’s using Testsuite Run Id’s

Testsuite Run ID - Testsuite Run Id is a combination of Testsuite and platform. These ids are always same for the combination of Testsuite and Platform.

Testcase Run ID - Testcase Run ID is a unique ID for each testrun.

Please check below API to get Testcase Run ID,

API : API to get Testcase Run IDs

URL : rest/execution/list/tcr

Method : POST

Request Header :a) Accept: application/json

                        b) usertoken : <usertoken>

                        c) scope : default

                        d) Content-Type: application/json

Request Body :

{

                                "tsrID": "<Testsuite run ID, e.g 102. This would be fetched

                                from QMetry UI,

                                Testsuite detail view - Linked Platform Grid - By

                                enabling the hidden column "TestSuite Run Id" > "

}

 

Response Body :

{

                "data": [{

                                                "TS_name": "<Testsuite

                                                name > ",

                                                "tsDescription": "<Testsuite Description>",

                                                "tcVersionID": < Testcase

                                                Version Id > ,

                                                "testCaseType": < Testcase

                                                Type Id > ,

                                                "testCaseTypeAlias": "<Testcase Type Alias>",

                                                "tsRunID": < Testsuite Run

                                                ID > ,

                                                "tcRunID": < Testcase Run

                                                Id > ,

                                                "orderId": < Order id > ,

                                                "tcID": < Testcase Id > ,

                                                "tctsID": < testcase

                                                Testsuite Id > ,

                                                "stepCount": < step Count > ,

                                                "startTime": "2015-09-08T11:30:59",

                                                "endTime": "2015-09-08T11:30:59",

                                                "isArchived": false,

                                                "logCount": 0,

                                                "domain": 0,

                                                "Status": 2,

                                                "StatusName": "co-notrun-ico",

                                                "StatusNameText": "Not

                                                Run ",

                                                "executedVersion": 1,

                                                "name": "<Name Of

                                                testcase > ",

                                                "entityKey": "<Testcase

                                                Entity Key > ",

                                                "priority": < Testcase

                                                Priority id > ,

                                                "priorityAlias": "<testcasepriority>"

                                }

                                ...

                                ..

                ],

                "total": < Total count >

}

------------------------------------------------------------------------------------------------------------------- 

Step 6 : Execute Service “Execute Testcase by Testcase Run” Id OR “Bulk Testcase Execution API’s” for changing execution status.

 

This API is used to change the status of test case. It requires below parameters:

1. entityIDs : These are testcase run id’s separated by commas. (Fetched in step 5)

2. dropID : This is nothing but Build id against which execution should be done OR It can be set as blank if you are not using Builds. (Fetched in step 3).

3. TsRunId : Testsuite Run Id is a combination of Testsuite and platform . (Fetched from step 4).

4. runStatusID : This is the execution status id (Fetched from step 2).

 

Below is the API “Execute Testcase by Testcase RunID : ”

 

API : Execute Test Case by Test Case Run Id.

URL :  /rest/execution/runstatus/bulkupdate

Method : PUT

Request Header :

                       Accept: application/json

                       Content-Type: application/json

                       scope:

                       usertoken:

Request Body :

                                {

                                "qmTsRunId": "<test suite run id e.g. 809>",

                                "entityType": "TCR",

                                "entityIDs": "<TCR ID e.g.3811>",

                                "runStatusID": < run status id e.g .1484 > ,

                                "dropID": "<drop id e.g. 1124 if applicable>",

                                "qmRunObj": ""

                                }

Response Body :

                                {

                                "success": true,

                                "code": "CO.UPDATE_RUNSTATUS_SUCCESS",

                                "data": [{

                                "qmTsRunId": "809",

                                "entityType": "TCR",

                                "entityIDs": "3811",

                                "runStatusID": 1484,

                                "dropID": "",

                                "qmRunObj": "",

                                "tcrStatus": "1484"

                                }]

                                }

---------------------------------------------------------------------------------------------------------------

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk