Automate message with Test execution content
Asked by Vojtech Kalab:

Hello there,  
I try to make autoamtion sending messages to MS Teams webhook once test automation is created.  
I would like to see test count, number of passed and failed test.  

There is a documentation from Xray:

<https://docs.getxray.app/display/XRAYCLOUD/Integration+with+Microsoft+Teams>

However my messages are still without number regarding tests.  
I don't know how to verify what is inside these variables like:  
`{{webResponse.body.data.getTestExecution.testRuns.results.status.name.match(``".*(PASSED).*"``).size|``0``}}`  
I make script in python to see what is in response json:

{'data': {'getTestExecution': {'issueId': '1028525', 'jira': {'key': 'CTB-4977', 'customfield_10033': None}, 'testRuns': {'results': \[{'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4847'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4848'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4849'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4873'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4850'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4615'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4972'}}}, {'status': {'name': 'PASSED'}, 'test': {'jira': {'key': 'CTB-4678'}}}\]}, 'testEnvironments': \[\], 'testPlans': {'results': \[\]}}}}

Automation log also confirm all my posts were successful ( so token etc should be correct )

So question is if these variables are up to date in xray documentation?

How can i check what is inside these variables?

Or do you have any other idea how to get information like test count, passed and failed tests?

There is better structured json file:

```
?
```

    json_data = '''{    "data": {        "getTestExecution": {            "issueId": "1028525",            "jira": {"key": "CTB-4977", "customfield_10033": None},            "testRuns": {                "results": [                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4847"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4848"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4849"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4873"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4850"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4615"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4972"}}},                    {"status": {"name": "PASSED"}, "test": {"jira": {"key": "CTB-4678"}}}                ]            },            "testEnvironments": [],            "testPlans": {"results": []}        }    }}'''


Answers:
author: Bill Sheboy
body: Hi [@Vojtech Kalab](/t5/user/viewprofilepage/user-id/5569113) -- Welcome to the Atlassian Community!

In your rule after the REST API call to get the test results from Xray, please try writing this to the audit log:

```
{{webResponse.body.data.getTestExecution.testRuns.results.status.name}}
```

That may confirm if the message is (or is not) being interpreted in a manner that can be parsed, or if it is plain text.

Kind regards,  
Bill

comments: author: Vojtech Kalab
body: Hi Bill,  
thank you for the kind welcome.

Thank you for your suggestion. It helped me to find out, my variables are empty, because i didn't check option:

<br />

*Delay execution of subsequent rule actions until we've received a response for this web request*

Thank you very much.


author: Vojtech Kalab
body: ```
?
```


Tags: cloud

jira-cloud