Axon provides fixtures when it comes to Saga and Aggregate testing. When it comes to projection testing developers are left on their own. It might be useful to provide a functionality in axon-test module for testing projections.
Here is a proposal:
ProjectionFixture fixture = ProjectionFixture.registerHandlingComponent(new MyProjection()) // here we can have scanning of @EventHandlers and @QueryHandlers
.registerResource(new MyRepository()); // or mock
fixture.given(events)
.whenQuery(query) // whenScatterGatherQuery, whenSubscriptionQuery
.expectResult(queryResult);
...
fixture.given(events)
.andSubscriptionQuery(query)
.when(event)
.expectEmittedUpdate(anUpdate);
Perhaps related, but would this fixture be able to test Error cases? Like having the errorhandler kick in or pushing TEP in error and retry mode?
big +1 I was looking to test queries but not possible
Yes, it is a bit frustrating to try to use the @QueryHandler/QueryGatway without testing support from the framework
+1. yes, I will agree, to have a possibility to test an event handling with some kind of Fixture will be helpful
Most helpful comment
big +1 I was looking to test queries but not possible