Testing platform events
When working with platform events in Apex, there are two potential scenarios that we will need to test and validate: when we are publishing platform events and when we are consuming platform events.
Testing whether platform events are publishing
Earlier in the chapter, we defined a DemonstrationEventPublisher
class as follows:
public with sharing class DemonstrationEventPublisher { public static void publishEventWithMessage(String message) { Demonstration__e demo = new Demonstration__e(); demo.Message__c = message; Database.SaveResult result = Eventbus.publish(demo); System.debug('The publish event was a success: ' + result.isSuccess()); ...