Understand Slack App Testing

Testing is a critical part of the development process. As with Apex development, we recommend that you use a test-driven development process, which is testing at the same time as code development. When working with Apex SDK for Slack, use the test harness framework to test your Slack apps.

Before you can package and distribute a Slack app, your unit tests must cover at least 75% of your Apex code, and all of those tests must complete successfully. See Understanding Testing in Apex.

The test harness is the entry point for testing Slack apps. It mocks the Apex SDK for Slack elements for running in a test environment, allowing the creation of a Slack state as needed.

We recommend that you test your actions, event handlers, slash commands, shortcuts, asserting against a real representation of your views and data.

These are useful concepts to understand for writing your tests.

Slack State

A mocked instance of the Slack infrastructure. Contains a default enterprise, team (workspace), channel, and user.

Slack User Session

A mock of a typical Slack Client allowing for interaction within the test harness. Contains state information for the user experience and allows simulating user interactions.

Test Components

The test components in the Slack.TestHarness class are a one to one mapping of components to Apex objects that can invoke actions and be asserted against during a test execution. Components are created from the generated view definition.

Testing is not yet supported for these features.

  • Threaded conversations
  • Private conversations
  • User management within channels
  • Channel-specific features like pinned messages
  • User-specific features like saved messages
  • Use of a client directly to emulate a call out to Slack