I am using a Jira Cloud Automation rule with Send web request to call the Xray GraphQL API getTestRunById, and the response is returned correctly.
I have added new Test Step statuses in Xray:
NA-PASSED
NORUN
PASSWSCRIPTERROR
I want to count how many test steps have the status NA-PASSED.
I created a variable using this smart value:
{{#webResponse.body.data.getTestRunById.steps}}
{{#if(equals(status.name, "NA-PASSED"))}}
{{status.name}}
{{/}}
{{/webResponse.body.data.getTestRunById.steps}}
The log output shows:
NA-PASSED NA-PASSED NA-PASSED NA-PASSED
Instead of listing the values, I need the count (for example: 4).
Using size did not work.
How can I get the count of NA-PASSED test steps using Jira Automation smart values?
When using conditional, list filtering this way, you may combine it with a math expression to get the result needed. For example:
{{#=}}
0
{{#myList}}
{{#if(myCondition)}}
+ 1
{{/}}
{{/}}
{{/}}
There is a 0 at the front for a default and each found value adds a + 1. When you want to sum another field, replace the 1 with that smart value.
For your scenario, please try this:
{{#=}}
0
{{#webResponse.body.data.getTestRunById.steps}}
{{#if(equals(status.name, "NA-PASSED"))}}
+ 1
{{/}}
{{/}}
{{/}}
Another way to do this for your existing result is to split() or match() on the text string and then use the list size function:
{{varMyVariableText.split(" ").trim.size|0}}
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am confused by your follow-up question as I already described how to find the count for the "NA-PASSED" test steps.
Did you mean some other status? If so, just change the value in the filter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.