AxonFramework icon indicating copy to clipboard operation
AxonFramework copied to clipboard

Projection Testing

Open m1l4n54v1c opened this issue 8 years ago • 9 comments

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

m1l4n54v1c avatar Aug 23 '18 08:08 m1l4n54v1c

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?

dzonekl avatar Mar 14 '19 13:03 dzonekl

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

Blackdread avatar Aug 16 '19 16:08 Blackdread

Yes, it is a bit frustrating to try to use the @QueryHandler/QueryGatway without testing support from the framework

hsdmiranda avatar Sep 19 '19 08:09 hsdmiranda

+1. yes, I will agree, to have a possibility to test an event handling with some kind of Fixture will be helpful

unkis avatar May 06 '20 04:05 unkis

Definitely +1

Arnaud-J avatar Feb 02 '22 09:02 Arnaud-J

+1.

kuangyl0212 avatar Apr 02 '22 05:04 kuangyl0212

+1

danstooamerican avatar Aug 03 '22 10:08 danstooamerican

+1

morphace avatar Jan 11 '23 08:01 morphace

Added this issue to release 5.0.0 as we intend to validate the feasibility of this in the new APIs.

smcvb avatar Aug 07 '24 12:08 smcvb