Skip to main content
5-Regular Member
May 9, 2024
Solved

How to get last test results on test case .

  • May 9, 2024
  • 1 reply
  • 1445 views
How can we get last test results in test case via api or compute fields?
Best answer by juwang

@alfonso_c Thank you so much.

This is very helpful. We want show the Last Run Result in Test Case Tracker , Due to your inspiration we add a custom Text field with 

   first(1,downstreamReferences(this).trackerTypes("testrun").{item| item.resolutions[0].name})  formula and it works!

juwang_0-1715752531454.png

 

1 reply

14-Alexandrite
May 10, 2024

Hi, @YW_10142311 , I assume this is related to a Test Run. If so, to which part do you refer, is it the below?

alfonso_c_1-1715323236415.png

14-Alexandrite
May 14, 2024

@YW_10142311, you gave "Kudos" to my previous question, so I assume you are indeed interested in getting that field with REST API or computation.

 

To get the Test Result of a Test Case's Test Run, you can chain 2 REST API calls:

 

1) Assuming the Main Test Run has ID 2094 as in my screenshot above, get its child items with GET /v3/items/2094/children:

{
 "page": 1,
 "pageSize": 25,
 "total": 1,
 "itemRefs": [
 {
 "id": 2095,
 "name": "Run of tc1",
 "type": "TrackerItemReference"
 }
 ]
}

 

2) Once you have the child item ID (2095), you can query its fields with GET /v3/items/2095/fields, the JSON will contain a part about the result:

 {
 "fieldId": 15,
 "name": "Result",
 "values": [
 {
 "id": 1,
 "name": "Passed",
 "type": "ChoiceOptionReference"
 }
 ],
 "sharedFieldNames": [],
 "type": "ChoiceFieldValue"
 }

 

With computation, you can e.g. add a custom Text field with the resolutions[0].name formula:

alfonso_c_1-1715667167091.png

 

alfonso_c_0-1715667127011.png

 

Does this help you?

juwang10-MarbleAnswer
10-Marble
May 15, 2024

@alfonso_c Thank you so much.

This is very helpful. We want show the Last Run Result in Test Case Tracker , Due to your inspiration we add a custom Text field with 

   first(1,downstreamReferences(this).trackerTypes("testrun").{item| item.resolutions[0].name})  formula and it works!

juwang_0-1715752531454.png