Ask a Question

Find the testcases within a testcycle via the api

Claddaghduff
Occasional Contributor

Find the testcases within a testcycle via the api

I want to insert an test execution result for a testcase but the endpoint for adding a new execution requires the testcycle key. I've tried to see how I can find the association between the testcase and the testcycle in both the testcase and the testcycle by getting each. I was hoping the testcycle would have a reference to the testcycle or the testcycle would have a list of all its testcases. Neither appears to be true. I use the following to retrieve the testcase: https://api.zephyrscale.smartbear.com/v2/testcases/<testcaseid>

testcycle: https://api.zephyrscale.smartbear.com/v2/testcycles/testcycles/<testcycleid>

Neither of these call return information relating to the other even though the testcycle contains the testcase.

I don't understand how I can create a test execution without this information. Any guidance would be appreciated.

 

TIA Alan

 

4 REPLIES 4
vinniew
Staff

Hi Alan, 

 

Did the other thread solve this issue? 

 

https://community.smartbear.com/t5/Zephyr-Scale-Questions/How-to-set-the-status-of-a-test-using-the-... 

 

Just dbl checking for reference? 

 

KR

 

Vinnie

Claddaghduff
Occasional Contributor

No, it uses a different way. As I'm using Zephyr Scale Cloud I access that via https://api.zephyrscale.smartbear.com/v2 and append the appropriate endpoint e.g. /testcases or /testcycles etc. (https://support.smartbear.com/zephyr-scale-cloud/api-docs/)
For accessing the API, you must generate an access key in Jira. To generate an access token, click on your profile picture at the page bottom left, and choose the option “Zephyr Scale API keys".
support.smartbear.com

 

 
This code here adds a test execution into Zephyr Scale for the test case however I've hard coded the values (just to make sure it will work) as I can't figure out how to get them via the api.
 
function createPostRequest(endpoint="/testcases")
{
  let address =  "https://api.zephyrscale.smartbear.com/v2" + endpoint;
  let request = aqHttp.CreatePostRequest(address)
 
  request.SetHeader("Content-Type", "application/json");
  request.SetHeader("Authorization", "Bearer <zephyr scale api token>")
 
  return request;
}
 
function createTestExecution()
{
  let test = getLastTest();
  let request = createPostRequest("/testexecutions")
 
  let requestBody = {
    "projectKey": "VRTWB",
    "testCaseKey": "VRTWB-T6",
    "testCycleKey": "VRTWB-R1",
    "statusName": "PASS",
    "testScriptResults": [
      {
        "statusName": "PASS",
        "actualEndDate": "2022-01-20T13:15:13.000Z",
        "actualResult": "User logged in successfully"}]
      }
  let str = JSON.stringify(requestBody)
 
  let response = request.send(str);
 
  Log.Message(response);
}
 
 
Claddaghduff
Occasional Contributor

Hi Vinnie,

 

I think I should have put this question in the Zephyr Scale community as it is related to that API. I am calling it from TestComplete but the data I'm looking for is designed by Zephyr Scale.

Claddaghduff
Occasional Contributor

Hi Vinnie,

Can you remove this or the duplicate I created. I added a post on Zephyr Scale Community as I hadn't realised that you could had the ability to move it across?

 

Thanks,

Alan

cancel
Showing results for 
Search instead for 
Did you mean: