TestBroker Class

Contains methods that simulate the successful delivery or failed publishing of platform event or change event messages in an Apex test.

EventBus

The following are methods for TestBroker.

  • deliver()

    Delivers platform event messages to the test event bus. Use this method to deliver test event messages multiple times and verify that event subscribers have processed the test events each step of the way.

  • fail()

    Causes the publishing of platform event messages to fail in the test event bus. Use this method to test Apex publish callbacks.

Delivers platform event messages to the test event bus. Use this method to deliver test event messages multiple times and verify that event subscribers have processed the test events each step of the way.

public void deliver()

Type: void

Enclose Test.getEventBus().deliver() within the Test.startTest() and Test.stopTest() statement block.

See Also

Causes the publishing of platform event messages to fail in the test event bus. Use this method to test Apex publish callbacks.

public void fail()

Type: void

For more information, see <link>Get the Result of Asynchronous Platform Event Publishing with Apex Publish Callbacks<link/> in the Platform Events Developer Guide.