By: Richard Clark, CTO at Provar

Richard Clark, CTO at Provar

The most important part of testing is using information about test results.

When data is shared with the right stakeholders at the right time and in the right way, the value of that information increases exponentially. By integrating Provar with your collaboration platform, like Slack, your team can find and fix bugs more quickly and improve the visibility of test results with real-time messaging in Slack. 

Accelerate your Feedback Loop with Provar Real-Time Test Results on Slack


Slack is a team collaboration application that can integrate with many external applications, and Provar is no exception. External apps can automatically post messages to Slack channels using incoming webhooks when specific events under their control occur. Using Slash Commands, users can query or update information in external apps within the Slack UI. You can even set up bots to listen to Slack conversations and automatically take action in response. These integrations allow you to turn Slack into a centralized real-time messaging hub across multiple systems.

It’s already straightforward to post to Slack as part of a CI/CD pipeline to include the complete test results, but sometimes, you may want to know about a failure well before you get to the end of the test execution. (Be sure to check out this customer success story that profiles how Canada Drives did just that and improves the visibility of automation run reports using Slack.)

“By integrating Slack into the Jenkins jobs we get all the automation runs reported to a Slack channel, including pass or fail details. This keeps devs, admins and testers informed of progress.” – Chandra Alahari, QA Automation Engineer at Canada Drives

Implementing Slack Real-Time Messaging for Provar Test Results


In this article, I demonstrate a simple integration scenario between Provar and Slack to provide a mechanism to post messages into a Slack channel. 

What does that mean? By integrating Provar with Slack, you can use a dedicated Slack channel to notify internal team members about significant test results in real time and define the test results you want to share. This would typically include notifications such as when a test step or case fails and a test run has been completed.

To create a Provar + Slack integration, you need Slack admin rights for your Slack workspace. I recommend creating a new Slack workspace to develop your integration so you don’t clutter your production Slack workspace with your unit test results. (You only need to change one value to connect it to your target workspace.)

Step 1: Create a Webhook


Incoming webhooks are a simple way to post messages from external sources (in this case, Provar) into Slack. They use normal HTTP requests with a JSON payload, including the message and other optional details. You can even include message attachments to display richly-formatted messages.

I’m going to use the same webhook for all of my examples. If you want to post messages to different channels, repeat the exercise for each channel you want to publish and carefully note each webhook URL.

Steps for how to create a webhook are documented by Slack here.

Sample of activating incoming webhook URLs for your workspace

Above: View of Slack webhook settings. Make sure you copy the webhook URL.

The webhook URL is automatically generated and unique to you. Go ahead and try out the curl command first so you know it’s working.

I added a custom username for the integration and uploaded a copy of the Provar logo.

Step 2: Add a New Provar Connection


Provar collates all connection details so you can have a single repository of system connections. Your new connection should be very similar, if not identical, to this:

Add a New Provar Connection

Above: View of Slack connection settings in Provar.

The connection defines the web service endpoint and authentication. In my example, I do not need authentication since the webhook we created above contains the service endpoint, which we haven’t restricted. 

Note: Always use HTTPS to secure the request parameters and the full URL.

Step 3: Create a Provar Callable Test


The next step is to create a simple Provar callable test capable of posting a message to the webhook URL. This allows us to pass result parameters and maintain a single utility test. It also means that your team can leverage the Provar + Slack integration without having to understand how to do the integration on their own.

You can create this yourself by following the steps below:

(1) Create a new test case in Provar. Call it SlackMessage. Do not start the Test Builder.

(2) Add a string Input Parameter and make your test callable. I’ve named my parameter ipMessage (the ip prefix is a naming standard I use, so I know it’s an input parameter rather than a local variable).

Create a Provar Callable Test for Slack real time messaging

In Slacks real time messaging, creating callable testing is needed to test case parameters

Above: View of Provar test case input parameter details and the test case settings.

(3) Add the newly created Slack connection to your SlackMessage test case.

(4) Add a REST web service step from the Test Palette and configure it to point to the webhook you created in Step 1. The resource URL should be a relative path to your created connection, i.e., everything after https://hooks.slack.com/services in the webhook URL. It would be best to store this as an environment variable for security purposes.

Make sure you set the Content-Type in the request header and JSON payload for the body, including your input parameter, as shown below:

Make sure you set the Content-Type in the request header and JSON payload for the body including your input parameter

Above: View of web request step parameters.

(5) Run your new callable test case and check everything is working before including it everywhere.

Pièce de résistance!


Now you have a working solution for posting messages to Slack from Provar, give yourself a pat on the back. All you need to do is drag and drop your callable Slack message test as a step into your other test cases and set the message parameter of what you want to write. Here are a few of mine:

A teardown test that logs all test run errors automatically in a single API call. Using teardown means you don’t have to change any existing tests. To test this, I wanted a test that fails on purpose using a Fail Test step:

Fail Test step sample for Slack real time messaging

Alternatively, use a Final step to log the result of a specific test automatically. You may want to make this conditional on failure only to be less chatty!

Integrating Slack with Provar


This is one of the many ways to integrate Provar with other applications to enhance test reporting. Suppose you’d like to learn more about these and different strategies to maximize Provar. In that case, you can refer to this case study highlighting a Provar customer Scaling Salesforce test automation with Canada Drives.

Further Reading


Suppose you want to learn more about writing Slack integrations, including tips on formatting your JSON payload. In that case, there’s a nice short Trailhead Module from Salesforce here. This is an excellent article by Christophe Coenraets about integrating Slack using Invocable Apex and Process Builder if you’re a Salesforce Consultant.

If you want to test your message formatting and payload string, use the Slack API Message Formatter to interactively test your string values quickly rather than running a test every time.