Answered

API Questions

1) What is the status variable? How do these values impact REST executions? Where is this definition documented? 

2) Can variables be added to REST URLs?

Example in a POST to:

https://jira.client.gov/rest/zapi/latest/execution/"@ID"/execute

How can "@ID" be replaced dynamically with a variable?

3) Issue with Get_Rest_Value.

Selection: Keys/Xpaths , id , BODY_TEXT 

Output:

{
"id": "126",
"responseMessage": "Cycle Postman Test created successfully."
}
 
Expected Result: Set Capturing Variable to '126'
Actual Result: set to entire output,
"{
"id": "126",
"responseMessage": "Cycle Postman Test created successfully."
}" 
1
13 comments
Avatar
Pavel Kasper

Hi David,
1) Status variable doesn't impact on Rest execution. It allows saving rest execution response code.
2) Yes, you can use variables and also data templates inside rest connection URL. In your case, you can use the next URL: https://jira.client.gov/rest/zapi/latest/execution/@ID/execute
3) You need to use 'BODY_JSON' to read 'id' from the response because the presented response is in JSON format. For the response in plain text format, you have to use BODY_TEXT, for the response in XML format, you have to use BODY_XML.

0
Comment actions Permalink
Avatar
David Beinhart

Thanks for the response!

Are you supposed to have Execute Rest and Get Rest Value back-to-back? That is what I had initially thought, but have had much more reliable performance using just GET Rest Value. 

My last problem is with how one of the responses is given. In Postman I was able to use JavaScript to parse this, but I am unable to in Subject7: 

{
"1203": {
"id": 1203,
"orderId": 1128,
"executionStatus": "-1",
}
}
 
1203 is the ID value I want to retrieve. I however, I can no longer request 'id' because the first 1203 is a Key and is in the way of accessing the other Values. I do not have a set name for this Key as 1203 will continue to increase with each successive call.  
0
Comment actions Permalink
Avatar
David Beinhart

The way we've been able to get around this with Postman is to use Regex. We could capture the entire response, and then parse it to pull out the first number, 1203. 

So the question is, if I were to capture the entire response using GET REST value and set the value to body text instead of JSON Body, I would then have then entire response as a variable. 

How could I use the Execute Javascript function to import this variable, parse it with REGEX and then save the value to be used as a new variable? 

0
Comment actions Permalink
Avatar
Jonathan Hotz

Hi David.

1) Is it strong requirement to use path with field "1203" or not? Our JSON parser is smart enough, so you can use simple record to find values by key.

For id in your case you can use .id | BODY_JSON type

For orderId in your case you can use .orderId | BODY_JSON type

As you can see there is no need to operate with full path using "1203" key.

Here is command sample:

{
"index" : 1,
"key" : "GET_REST_VALUE",
"model" : {
"statusVariableName" : "status",
"validationRequired" : false,
"variableName" : "id,orderId",
"fields" : [
{
"key" : ".id",
"type" : "BODY_JSON"
},
{
"key" : ".orderId",
"type" : "BODY_JSON"
}
],
"excludeCharacters" : [ ],
"rest_connection" : "david",
"validation_file" : "<NOT SELECTED>"
},
"skip" : false,
"runtimeOption" : "HALT",
"customCaption" : ""
}

 

2) Our EXECUTE_JAVASCRIPT command doesn't return any value. If you want to do anything via Javascript and return result of operation, you should use GET_WEB_VALUE command with Javascript option. Don't forget that your script should be finished with return statement.

0
Comment actions Permalink
Avatar
David Beinhart

To be clear, 1203 is an ID value and will change for each execution. The problem I am having is how to set the path to the key value pair ID:1203 if it itself is a value for the key 1203. In my other rest executions, the ID is not given twice and so the response is

{id:1203, otherKey1:otherValue1, otherKey2:otherValue2} and not,

{

    {1203:

         {id:1203, otherKey1:otherValue1, otherKey2:otherValue2}

       }

I am unsure about your suggestion for executing the GET_REST value, when I run the attached, I get the entire REST execution back and not the specific ID value. 

 

I've realized trying to run Regex on the variable will also be difficult given the multiple internal strings causing Syntax errors.

0
Comment actions Permalink
Avatar
David Beinhart

0
Comment actions Permalink
Avatar
Jonathan Hotz

As I see on screenshot you selected BODY_TEXT and not BODY_JSON as mentioned.

Also you provided key id and not .id as mentioned :)

 

0
Comment actions Permalink
Avatar
David Beinhart

Thanks :) 

Final question...  I finally have the API calls working, but now need to put them together in an execution set. 

I had one "set-up" test case to create what is basically a folder structure in Zephyr (cycles --> folders ---> individual test cases) 

The API call creates a unique execution ID for each test case (That 1203 number I was trying to capture earlier)  

And in Subject7 I can use call backs to update based on Condition (Pass/Fail) 

The issue is, I need to have these execution IDs to correlate to the Subject7 test cases.

Should I break up the setup test case to something like this (Everything being an individual test case): 

1) Create Cycle  

2) Create Folder 

3) Add execution for test 1

4) Execute test 1 (execution_id will be correct for test 1 when callback is executed) 

5) Add execution for test 2 

6) Execute test 2 (execution_id will now be correct for test 2 when callback is executed) 

7) Create new folder 

8) So on and so forth as needed

Are Cloud Executions executed in order every time?

I need to ensure that 1) Cycles are created before test cases are executed (or at least before their results are written to Zephyr) and that 2) the execution_ids are timed with the Callbacks for Pass/Fail so they are matched to the correct test case. 

 

0
Comment actions Permalink
Avatar
Alexander

David, I suggest you do it this way:

  • add execute_rest 'create_execution' step for each test, it will set execution ID into the variable @ZephyrExecutionID. (you can add this step in the trigger instead of test case directly because it does not relate to the application under test)
  • add a callback 'update_execution_status' on test case execution level using @ZephyrExecutionID inside the url, you can also use @test_case_execution_status variable to determinate a status or just add two callbacks for each condition onPass/onFail

0
Comment actions Permalink
Avatar
David Beinhart

Thanks for the response, and finding how to chain test cases in an execution set has been helpful, but I am still stuck because I can't seem to add a test case to an execution set more than once. 

It looks like I won't be able to have one test case for all of the Zephyr API calls because I need to keep track of individual IDs. So if my execution set is Zephyr API (setup cycle), (set up folder) (create execution) execute Sub7 test case, (update execution), --> how would I repeat the API functions in ()'s without have to redefine the function a bunch of times or edit the underlying test cases?  

0
Comment actions Permalink
Avatar
Rex Feizi

Would you please elaborate on the following:

 

  1. Keeping track of individual ID's
  2. Does Zephyr team provide any help? 
  3. Does Zephre has an endpoint that handles their specific flow altogether in one callback
0
Comment actions Permalink
Avatar
David Beinhart

1) I need to keep track of the individual ids generated for everything: Cycle, Folder, Individual Test Cases

2) They were able to explain their calls and help me get this working in PostMan.

3) No there is no endpoint to my knowledge that provides the entire flow in one callback. 

There are calls for A) Creating a Cycle, B) Creating Folders C) Creating Executions D) Updating Executions

 

In an ideal world, I could reuse test cases in a Subject7 execution set.

Something like:

1.A) Create a Cycle [Zephyr API]  input: @name, @date, @description, @version_id@project_id --> output @cycle_id

    2.A) Folder [Zephyr API] input: @cycle_id, @name, @description, @project_id, @version_id --> output                @folder_id

        3.A) Create Execution [Zephyr API]  input: @folder_id --> output: execution_id

        3.B) Test Case [Subject 7 Test Case] output: Pass/Fail  

        3.C) Update Execution (this will be implemented with Triggers and will need to be called immediately                    after the execution to ensure the @execution_id is correct

Where 2 and 3 are repeated as needed (2 for every grouping of test cases and 3 for every test case.)

But I can't reuse test cases in an Execution Set and maintaining the order of executions is imperative. 

0
Comment actions Permalink
Avatar
Rex Feizi

David, 
Thank you for your detail response. Let me put things in perspective: 

  1. Subject7 Platform has been designed such that it could scale executions at high volumes. In order to do so, all test case executions are independent of each so we can achieve maximum parallelism. This practice is well aligned with the industry standard and best practices. 
  2. Subject7 Platform provides a Callback API that can be used upon completion of execution. The receiving endpoint on well-designed systems would be able to use the execution artifacts however they are needed. Unfortunately, as we have seen Zephyre doesn't provide such API's as it was not designed to be used with open systems. There were hardcoded values in their API's which is usually not a good indication.  
  3. Subject7 Platform doesn't force a process on its users, meaning, users can use the platform however they see fit for their project. However, it seems like Zephre has a strict life cycle that is rigid and you need to follow it closely. 
  4. We cannot introduce a flaw (i.e. dependency) in our system where test cases keep states (in this case variables are passed between them), to compensate for a lack of capable API in other systems. We provide all required information and API's for integration, if a 3rd party requires something special, in this case, a consolidated API with defined states, then they must provide it. 

 

I have the following recommendation for your project:

  1. The fastest solution is to create an Endpoint yourself with a database backend and consolidate Zephr API's into one endpoint and have the callback in Subject7 Platform call your own endpoint. 
  2. Submit an enhancement request with Zephyr to provide the required API as described above. Subject7 platform provides generic callback at any stage of the execution, it's up to the endpoint to manage the callback, as it's generic. 
  3. Re-evaluate the tool that you have chosen and see if it actually scales and integrates with 3rd party systems. Test case management is usually a smaller sub-system and it's best when it doesn't force a process on a given projects. 


Do not hesitate to contact Subject7 should you have any other questions or comments. As for this thread, your "ideal case" would have compromised our platform. 

 

Thanks, 

 

--Rex

0
Comment actions Permalink

Please sign in to leave a comment.