Projection Testing
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
Definitely +1
+1.
+1
+1
Added this issue to release 5.0.0 as we intend to validate the feasibility of this in the new APIs.