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.

What to test in a Slack App 

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.

Test Harness

The Test Harness mocks out necessary elements to run in a test environment. It allows the creation of a fresh Slack state at will.

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.

Considerations and Limitations 

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

Beta Feature

This feature is not generally available. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in SFDC’s sole discretion, and SFDC may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.