Axonframework: Projection testing

Created on 23 Aug 2018  路  4Comments  路  Source: AxonFramework/AxonFramework

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);
Could Feature

Most helpful comment

big +1 I was looking to test queries but not possible

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raphael-jungers picture raphael-jungers  路  6Comments

wangshihui picture wangshihui  路  4Comments

tunovic picture tunovic  路  5Comments

donovanmuller picture donovanmuller  路  3Comments

benneq picture benneq  路  3Comments