How to test event choreography? #96
Replies: 1 comment 14 replies
-
| That's an interesting question. The natural scope in focus for Spring Modulith is indeed a module in isolation. That's what our integration test support is centered around. That said, there's also the  I wouldn't mind hearing about the results you can achieve with that.  | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was wondering how I can write integration tests that verify a business process that is driven by application events (a saga essentially).
For example, the creation of a new account triggers an invitation. After the invitation is accepted the account is activated.
The corresponding events are
AccountCreationInitiated,InvitationAccepted, andAccountActivated.I want to be able to write a test, that:
AccountActivatedwas publishedI am able to write steps 1, 3, and 4 but step 2 is tricky. The problem is, that step two is performed by an
@ApplicationModuleListener. This event handler is never called inside my test (it works if I start my application normally). I think it is because it waits for the transaction to finish but this never happens inside my test I think. The test runs fine if I replace the@ApplicationModuleListenerwith@EventHandler.I am also not sure how the
@Asyncannotation inside@ApplicationModuleListenerinterferes with my tests and how to reliably test these event handlers. I already added delays and timeouts to my verify calls which did not change the behavior.Lastly, I would like to know if it makes sense to publish events inside my test methods to see how my system behaves.
How should I go about writing my integration tests?
Beta Was this translation helpful? Give feedback.
All reactions