# Slack Integration
In this article, we will look at, how we can integrate Slack with vREST NG. This integration will keep your team in sync with your APIs status.
Table of Contents:
# How this integration works?
Let's briefly look at, how this integration actually works:
- Import the desired built-in template for this integration.
- This integration adds a
Post Test Case Iteration Hook
which will be executed whenever a test case is failed. And the details will be posted on configured Slack Channel. - This integration also adds a
Post Test Run Hook
which will be executed for each test run execution. And It will post the test run summary information to the configured Slack channel.
Now, let's see the step-by-step instructions on how you may integrate Slack with vREST NG Application.
# Step 1: Import the Slack Integration Template
Now, just visit the Hooks tab in vREST NG Application and click on the "Show Built-in Integrations" option available at the bottom in the left pane. It will show all the available integrations. Just select the desired integration and click on the Import
button.
# Step 2. Understand the data which is imported
Let's review the data which is imported by this import process. You may skip this step if you don't want to see the details. We will continuously improve our integrations based on user feedback. In this step, we will mention the impact of re-import of the integration. You may safely remove any of the integration files and re-import them. However, if you have done any customizations then you may need to do it again if you delete the files.
File Path | Remarks |
---|---|
environments/default.json | This file will be updated with some integration-specific variables. If some of the variables already exist then they won't be changed. |
hooks/send_slack_notification_on_api_test_failure.json | Post Test Case Iteration Hook to post the API Test status on Slack Channel on test failure. If a file with this name already exists then the import process will not change the contents of this file. |
hooks/send_slack_notification_on_test_run_summary.json | Post Test Run Hook to post the entire test run summary information on Slack Channel. If a file with this name already exists then the import process will not change the contents of this file. |
utilities/getSlackChannelMessageForTestFailure.js | Utility Method for generating Slack channel message for API Test failure. If a file with this name already exists then the import process will not change the contents of this file. |
utilities/getSlackChannelMessageForTestRunSummary.js | Utility Method for generating Slack Channel message for entire test run summary information. If a file with this name already exists then the import process will not change the contents of this file. |
hooks.json | Hooks file to configure the desired hooks for integration. |
# Step 3: Configure the global variables
Now, just visit the Environment/Variables
section in the Configuration
tab and configure the following variables which the import process has just defined.
Variable Name | Description |
---|---|
slackWebHookURL | Slack Web hook URL. You may configure the incoming webhook by following the Slack Guide (opens new window). |
slackUsername | Slack username information |
slackChannel | Slack Channel name on which notifications will be posted. |
slackHookEnv | Provide the environment name in which you would like to execute this hook. For testing purposes, you may use the value default or whatever environment you are using for your local test development. |
# Step 4: Customizing the hook
Although, you may customize every part of this hook as per your needs. But specifically, you would be interested in changing the notification message formats which the vREST NG Application sends to Slack. For that purpose, you may look at the following sections:
- Check
Utility Methods
>>getSlackChannelMessageForTestFailure
for Test Failure Notification Message. - Check
Utility Methods
>>getSlackChannelMessageForTestRunSummary
for Test Run Summary Notification Message.
# Step 5: Verifying the Integration
To verify the integration, simply execute some of the tests, at least one of them should fail. Make sure you are executing them in an environment as per the configured hook condition.
Now see the result for a failed test case and Open the Hooks sub-tab for that test case. If you see the green signal for the Slack hook then your integration is working fine. You may also verify the integration by looking at the message in the Slack Channel.
To verify the Post Test Run Hook, you may click on Hook Results
available in the Test Cases Tab >> Test Run Status (available in Left Pane at the bottom). A dialog window will appear to show the results:
That's it. If you face any issues in this integration. Feel free to reach out to us at support@vrest.io
.