Looking for a way to trigger an event for testing custom event subscriber
You can use the event_dispatcher service to trigger an event.

Use this code to trigger your event.

\Drupal::service('event_dispatcher')-&gt;dispatch(MyModuleEvents::MY_EVENT, new MyModuleEventClass());


Of course you have to replace the names with your real names.

You can run the code using drush php.

You can read more about subscribing and dispatching events here.