Integrate test results into Slack [step-by-step tutorial]

One of the great things about Slack is the long list of integrations available. Whether it’s an integration as foundational as Google Drive, GitHub, or Zendesk — or as whimsical as Lunch Train — there are Slack integrations for a wide range of use cases.

Here’s an example of Slack’s GitHub integration:

pasted image 0 8

With that backdrop, we’d like to show you how to integrate your Applitools Eyes visual UI test results into one of your Slack channels — something that our customers have frequently requested.

This step-by-step tutorial uses the Slack incoming webhooks API.

First, some background:

Slack provides APIs to users to create applications and to automate processes, such as sending automatic notifications based on human input, sending alerts on specified conditions, and more. The Slack API has been noted for its compatibility with many types of applications, frameworks, and services.

Once you build this tutorial, you’ll be able to view test results on any Slack client: your laptop, your phone. Or even via notifications on your Apple Watch, if you’re stuck in a meeting and don’t want to open your phone. You’ll be the first to know if your app has a visual glitch that you’ll need to fix.

With that, let’s dive into what you need to do  to bring Applitools into your Slack channel:

Step 1: Set up your Slack endpoint

  1. Per Slack recommendations, create a “sandbox” account for Slack for your experiments before integrating it with your team Slack account: https://slack.com/create
  2. Follow these instructions to see how you post your first “Hello world” message to your new Slack channel: https://api.slack.com/tutorials/slack-apps-hello-world
  3. Copy and keep your webhook URL (always better to add this webhook URL to your environment variables, but I’ll leave it to you).

hw incoming webhook table after

Step 2: Getting Applitools Eyes Test Results

  1. Switch to whatever IDE you use to write automated test scripts that call the Applitools API, and open one of those scripts.
  2. Towards the end of your test scripts, you should have a call to eyes.Close(). Here’s its documentation for our Java, JavaScript, C#, and Python SDKs. For scripts written in Java, it will look something like this:
    TestResults res = eyes.close(false);
  3. This call returns a TestResults object. Additional information about Applitools TestResults can be found here.
    
    

Step 3: Connecting The Dots

The example below is in Java; however, you can figure out how to achieve this in any language you are using (with minor differences) as the TestResults object is accessible also in JavaScript, Python, Ruby, C#, and PHP. I’ve followed the instructions in this article to create the code below but feel free to customize it to your specific team needs.

1. Create class EyesSlack and add the following code in it:

2. Now let’s see how we use this class in our tests:

3. All you need to do now is run it to see your Applitools Eyes Test Results right in your Slack channel.

Here is an example of the screen message in Slack:

pasted image 0 9

If you want to see my own experience putting together this blog post, check out this video:

Now that you tested it in your sandbox you are ready to merge into your team slack account – simply replace the webhook URL and you are good to go.

Looking for additional integrations with Applitools? Here are my favorites:

Applitools lets you deliver visually perfect web and mobile apps with AI-powered end-to-end visual testing & monitoring.

Stay updated by signing up for our newsletter

View our Privacy Policy