Slack is a popular communication platform adopted by many development and non-development teams.
Teams use it daily to collaborate, make calls, share information, ask for help, and be notified of certain events to increase visibility of the status of the projects they're working on.
In this article, we'll see an everyday use case: sharing test results with the team in their collaboration tool (i.e., "Slack"). However, Xray and Jira's built-in automation capabilities can implement many more use cases.
To integrate with Slack, we can set up an incoming webhook in a channel and send notifications (i.e., "messages").
This common use-case is about sharing information about test results, usually from test automation, to a Slack channel so the team can be aware of testing progress and analyze the results if needed.
At high-level, we will:
|
{ getTestExecution(issueId: "{{issue.id}}") { issueId jira(fields: ["key","customfield_10033"]) testRuns(limit: 100){ results{ status{ name } test { jira(fields: ["key"]) } } } testEnvironments testPlans(limit: 1) { results{ jira(fields: ["key"]) } } } } |
{{webResponse.body.data.getTestExecution.testRuns.results.size|0}} |
{{webResponse.body.data.getTestExecution.testRuns.results.status.name.match(".*(PASSED).*").size|0}} |
{{webResponse.body.data.getTestExecution.testRuns.results.status.name.match(".*(FAILED).*").size|0}} |
{{webResponse.body.data.getTestExecution.testRuns.results.status.name.match(".*(TO DO).*").size|0}} |
{{#=}}{{totalTests}} - {{passedTests}} - {{failedTests}} - {{todoTests}}{{/}} |
{{webResponse.body.data.getTestExecution.testPlans.results.jira.key}} |
{{webResponse.body.data.getTestExecution.testEnvironments.join(",")}} |
{{webResponse.body.data.getTestExecution.testEnvironments.join(",")}} |
As a mere example, for the "failure" image we can use the following one.
https://docs.getxray.app/s/e1tqew/8402/f0863dd17de361916f7914addff17e0432a0be98/_/images/icons/emoticons/error.png |
As a mere example, for the "success" image we can use the following one.
https://docs.getxray.app/s/e1tqew/8402/f0863dd17de361916f7914addff17e0432a0be98/_/images/icons/emoticons/check.png |
{ "blocks": [ { "type": "context", "elements": [ { "type": "mrkdwn", "text": "Test results were reported for project *{{project.name}}*" } ] }, { "type": "context", "elements": [ { "type": "mrkdwn", "text": "{{issue.summary}}" } ] }, { "type": "section", "text": { "type": "mrkdwn", "text": "{{notificationMsg}}" }, "accessory": { "type": "image", "image_url": "{{notificationImageUrl}}", "alt_text": "test results" } }, { "type": "divider" }, { "type": "section", "text": { "text": "Test Execution details, including its Test Runs", "type": "mrkdwn" }, "fields": [ { "type": "mrkdwn", "text": "*Test Execution*\n<{{issue.url}}|{{issue.key}}>" }, { "type": "mrkdwn", "text": "*Version*\n{{issue.fixVersions.name}}" }, { "type": "mrkdwn", "text": "*Revision*\n{{issue.Revision}}" }, { "type": "mrkdwn", "text": "*Test Environment(s)*\n{{testEnvironments}}" }, { "type": "mrkdwn", "text": "*Test Plan*\n{{testPlanSlackUrl}}" }, { "type": "mrkdwn", "text": "*Total tests*\n{{totalTests}}" }, { "type": "mrkdwn", "text": "*Passed tests*\n{{passedTests}}" }, { "type": "mrkdwn", "text": "*Failed tests*\n{{failedTests}}" }, { "type": "mrkdwn", "text": "*To Do tests*\n{{todoTests}}" }, { "type": "mrkdwn", "text": "*Other tests*\n{{otherTests}}" } ] } ] } |