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()); Â Â Â ...