Making Test Results Pop with Slack: A Colorful Guide ๐
The Spotlight on Test Scores ๐ฏ
In the world of creating cool apps and websites, tests are like secret heroes that make sure everything works perfectly. But, what if nobody sees the signals from our heroes? That's why showing test scores where everyone can see them is super important. You can use any chat app where your team hangs out, like Google Chat, Slack, or others, to share these scores.
Why Sharing in Chat Apps Rocks ๐ฃ
Chat apps are like the main hangout for your team. When you share test scores there, it's not just an update; it's a way to start chats and get things moving. It's like turning "I didn't see the test scores" into "Let's fix this together!"
The Power of Colors and Emojis ๐ฆ
Colors and emojis can speak faster than words:
๐ข Green for "Yay, everything's great!"
๐ก Yellow for "Hmm, take a look!"
๐ด Red for "Oops, we need to fix this!"
Using emojis makes everything clearer and more fun!
How to Get Started ๐งฉ
Here's a simple guide to light up your team chat with test scores:
Pick Your Chat App ๐ฒ : Choose the app where your team hangs out and talks work. Slack, GoogleChat, Team, Email.
Craft Your Message ๐ฌ : Think of putting together a fun message like building with blocks. You can share test scores and make them pop with emojis.
Automate Your Tests ๐ฆพ: Use CICD tools to run your tests and schedule test for Smoke Test or Regression.
Keep Secrets Safe ๐คซ: If you're using Webhooks or special links, make sure to keep them secure, just like secret codes!
Pick Your Color Code Based on test result. ๐จ:
If test result over 95%? Go with ๐ข green.
If test result between 85% and 95%? Choose ๐ก yellow.
If test result below 85%? It's time for ๐ด red.
Share, React, Repeat ๐: After setting it up, share your results, see how the team reacts, and keep improving.
Emojis and Colors Make It Better ๐
Emojis and colors aren't just fun; they're like quick signals that help everyone understand test results at a glance:
๐ข Great job! (Score > 95%)
๐ก Almost there, need a little tweak. (Score 85-95%)
๐ด Attention needed, let's fix it. (Score < 85%)
Wrapping Up with Fun ๐
By using automation tools with your favorite chat app and a splash of colors and emojis, checking test scores becomes an engaging and fun part of your team's day. It's not just about making things automatic; it's about ensuring everyone sees and reacts to every test score, making your project better together.
So, let's make our test scores shine in our team chats, keeping our projects healthy and our team in sync. Time to brighten up our chats! ๐๐จ
Example of using Slack.
Use Slack Block Kit builder to craft your message, here are the templates for each.
Choose the approach, implement in your test automation framework or on CICD tools like Azure Devops, Jenkins and Github action.
Create secrets in you repo to store Webhook or Channel ID.
After execution calculate
TOTAL_TESTS
,PASSES
,FAILURES
,SUCCESS_RATE
Use these info in Slack Payload message.
Screenshots example ๐ผ๏ธ
Slack Implementation with Github Action
test-result.txt
is test result generated by mvn command
. And then use awk
to extract value.
Content of test-result.txt
in this example.
Total tests run: 1150, Passes: 1150, Failures: 0, Skips: 0
Example for yaml file.
- name: Slack Message
if: always()
id: result
run: |
CONTENT=$(cat target/test-result/test-result.txt)
echo $CONTENT
TOTAL_TESTS=$(echo $CONTENT | awk -F'[ ,]+' '{print $4}')
echo "totalText=$TOTAL_TESTS" >> "$GITHUB_OUTPUT"
PASSES=$(echo $CONTENT | awk -F'[ ,]+' '{print $6}')
echo "pass=$PASSES" >> "$GITHUB_OUTPUT"
FAILURES=$(echo $CONTENT | awk -F'[ ,]+' '{print $8}')
echo "fail=$FAILURES" >> "$GITHUB_OUTPUT"
SKIPS=$(echo $CONTENT | awk -F'[ ,]+' '{print $10}')
echo "skip=$SKIPS" >> "$GITHUB_OUTPUT"
if [ "$TOTAL_TESTS" -eq 0 ]; then
SUCCESS_RATE=0
else
SUCCESS_RATE=$(awk "BEGIN {printf \"%.2f\", ($PASSES/$TOTAL_TESTS)*100}")
fi
echo "rate=$SUCCESS_RATE" >> "$GITHUB_OUTPUT"
SLACK_MESSAGE_TEXT=""
INITIAL_COMMENT=""
if [ "$PLATFORM" == "Api" ]; then
SLACK_MESSAGE_TEXT="๐ Api health check Here."
INITIAL_COMMENT="*_Download the API health check test report for Detailed View_*"
elif [ "$PLATFORM" == "Android" ]; then
SLACK_MESSAGE_TEXT="๐ค Android Test Result Here."
INITIAL_COMMENT="*_Download the Android test report for Detailed View_*"
else
SLACK_MESSAGE_TEXT="๐ iOS Test Result Here."
INITIAL_COMMENT="*_Download the iOS test report for Detailed View_*"
fi
SLACK_MESSAGE_PAYLOAD=$(cat << EOF
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "$SLACK_MESSAGE_TEXT",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The <${CURRENT_JOB_URL}|latest test run> has completed. Here are the details:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "๐งช *Test Suite:* $TEST_TYPE Test\n\n๐ข *Total Tests:* ${TOTAL_TESTS}\n\nโ
*Tests Passed:* ${PASSES}\n\nโ *Tests Failed:* ${FAILURES}\n\nโฉ *Skips:* ${SKIPS}\n\n๐ *Success Rate:* ${SUCCESS_RATE}%"
}
},
{
"type": "divider"
}
]
}
EOF
)
if [ $(echo "$SUCCESS_RATE < 100" | bc) -ne 0 ]; then
echo "๐ฎ Sending this payload to Slack: $SLACK_MESSAGE_PAYLOAD"
curl -X POST -H 'Content-type: application/json' --data "$SLACK_MESSAGE_PAYLOAD" $SLACK_WEBHOOK
else
echo "๐ Hooray! The tests were completely successful with a 100% success rate. No issues detected. ๐"
echo "Success Rate: $SUCCESS_RATE%"
fi
- name: Summarized
run: |
echo "๐ **Build and Release Odyssey** ๐" >> $GITHUB_STEP_SUMMARY
echo "Dive into the details of our latest software expedition!" >> $GITHUB_STEP_SUMMARY
echo "| ๐ Stellar Details | ๐ Value |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- | " >> $GITHUB_STEP_SUMMARY
echo "| ๐ฐ Release Number | $RELEASE_NUMBER |" >> $GITHUB_STEP_SUMMARY
echo "| ๐ฅ Platform | $PLATFORM |" >> $GITHUB_STEP_SUMMARY
echo "| ๐งช Test Type | $TEST_TYPE |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY # Empty line to separate the tables
echo "๐งญ Ready for the next adventure? Onward to the test results!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY # Empty line to separate the narrative from the table
echo "๐ **Automated Test Chronicles** ๐" >> $GITHUB_STEP_SUMMARY
echo "Behold the saga of our automated tests in vivid detail!" >> $GITHUB_STEP_SUMMARY
echo "| ๐ Test Metrics | ๐ฏ Value |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- | " >> $GITHUB_STEP_SUMMARY
echo "| ๐งฎ Total Tests | ${{ steps.result.outputs.totalText }} |" >> $GITHUB_STEP_SUMMARY
echo "| โ
Tests Passed | ${{ steps.result.outputs.pass }} |" >> $GITHUB_STEP_SUMMARY
echo "| โ Tests Failed | ${{ steps.result.outputs.fail }} |" >> $GITHUB_STEP_SUMMARY
echo "| ๐ Success Rate | ${{ steps.result.outputs.rate }}% |" >> $GITHUB_STEP_SUMMARY
Subscribe to my newsletter
Read articles from Halmurat T directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by