Slack Integration - Need ability for test results (pass / fail) to post to a slack channel


#1

Slack Integration - Need ability for test results (pass / fail) to post to a slack channel. Add the following options under Preferences > Team Collaboration > Send message to slack when:

Test Case passed
Test Case failed
Test Suite passed (every test case in Test Suite passed)
Test Suite failed (when 1 or more Test Cases in the Test Suite failed)

Also, You have Create Keyword currently, but it would be nice to have Update Keyword as well.


#2

Hey Don,

Slack integration has been planned for the future release of Katalon Studio. However, I don’t have the exact ETA on this. Look out for our update!

Thanks for suggesting to make Katalon Studio better,
Liam


#3

I needed the same feature, so created it myself using the Test Listeners. Before you start, you need to create a new Web Service Object and define the Slack API Web Hooks (Google it). Once you have that you can create a Slack Test Listener Class. I also have a Global Variable “integrateSlack”, which is a boolean value so that we can turn this off and on whenever we want.

class Slack {

private RequestObject slackMessage = findTestObject(‘APIs/Slack’)

private String testCaseStatus = “ERROR”

private String testSuiteStatus = “PASSED”

private void postToSlack() {

if (GlobalVariable.integrateSlack) {

WS.sendRequest(slackMessage)

}

}

/**

* Executes before every test suite starts.

* @param testSuiteContext: related information of the executed test suite.

*/

@BeforeTestSuite

def notifyBeforeTestSuite(TestSuiteContext testSuiteContext) {

slackMessage.setHttpBody(’{“text”: “’ + testSuiteContext.getTestSuiteId() + ': Started”}"’)

postToSlack()

}

/**

* Executes before every test case starts.

* @param testSuiteContext: related information of the executed test suite.

*/

@BeforeTestCase

def notifyBeforeTestCase(TestCaseContext testCaseContext) {

slackMessage.setHttpBody(’{“text”: “’ + testCaseContext.getTestCaseId() + ': Running”}"’)

postToSlack()

}

/**

* Executes after every test case ends.

* @param testSuiteContext: related information of the executed test suite.

*/

@AfterTestCase

def notifyAfterTestCase(TestCaseContext testCaseContext) {

testCaseStatus = testCaseContext.getTestCaseStatus()

Map variables = testCaseContext.getTestCaseVariables()

//slackMessage.setHttpBody(’{“text”: “’ + testCaseName + ': ’ + testCaseStatus + ‘\n’ + variables.toString() + '”}"’)

slackMessage.setHttpBody(’{“text”: “’ + testCaseContext.getTestCaseId() + ': ’ + testCaseStatus + '”}"’)

postToSlack()

if (!testCaseStatus.equals(“PASSED”)) testSuiteStatus = “FAILED”

}

/**

* Executes after every test suite ends.

* @param testSuiteContext: related information of the executed test suite.

*/

@AfterTestSuite

def notifyAfterTestSuite(TestSuiteContext testSuiteContext) {

slackMessage.setHttpBody(’{“text”: “’ + testSuiteContext.getTestSuiteId() + ': ’ + testSuiteStatus + '”}"’)

postToSlack()

}

}


Katalon intergration with Bamboo CI
#4

Hey Caleb,

Thanks for sharing! I’ll give this a try.

Don


#5

Hi Don,

Something to note that I hope Katalon will improve in the future:

  • Test Listeners are triggered for all subprocesses (test cases called by other test cases) and keywords. This causes a lot of extra test listener calls, whether notifications or any other task that we really only wanted fired at the beginning/end of the primary (top-level) test case.
  • Katalon needs to add additional features to their TestSuiteContext and TestCaseContext. IE. we would like to see a TestSuiteContext.getTestSuiteStatus() feature, because it is more important to us to report the start and end of a test suite with the completion status.

You may have already discovered this, but I wanted to document this for Katalon too.

Caleb


#6

Hi Caleb,

Thanks for the note. I googled, but can you provide any more details on this part: create a new Web Service Object and define the Slack API Web Hooks. I have the integration setup in Slack for the incoming webhook and the the webhook URL, not sure how to set this up in Katalon. Any example you could provide?

Thanks,

Don


#7

Hi Caleb,

Got it working.

Thanks,

Don


#8

Hi Don and Caleb,

Any chance you can post the step by step of setting up the Web Service Object. I already have the information for the Slack API Web Hook (e.g. hook token, content type, accept charset), just not sure how to configure and test the Web Service.

Thanks,
Ben


#9

Hi Ben,

Please look over Katalon’s documentation for creating the Web Service Request Object:
https://docs.katalon.com/display/KD/RESTful
I don’t know what else you would need.

Caleb


#10

Caleb Wood said:

Hi Ben,

Please look over Katalon’s documentation for creating the Web Service Request Object:
https://docs.katalon.com/display/KD/RESTful
I don’t know what else you would need.

Caleb

Thanks Caleb, will look into that!!

Ben


#11

The documentation is very clear, thanks Caleb


#12

+1 for this.


#13

I know it seems obvious, but I am just learning to do some things and would really appreciate even screen shots of both components. Pretty please?