Extra event handlers in uni tests

Hi,

I want to use the GivenWhenThenTestFixture to test the behaviour of a certain event handler. So I set it up normally with the aggregate root and register my extra event handler:

AnnotationEventListenerAdapter.subscribe(new MySpecialEventHandler(),fixture.getEventBus());

But this event handler never receives any events.

I had a look at the code of RecordingEventBus:

@Override
public void subscribe(EventListener eventListener) {
}

Seems that the event bus simply ignores all subscribe request.

So how could I test do such extended tests?

This sounds more like an integration test. The fixtures are really meant to test the Command Handling component in isolation.

If yuo want to test an event handler, you would normally write a specific unit test and call the methods directly. You could also choose to set up a SimpleCommandBus, register the handler and send events directly to the bus.

Cheers,

Allard