Closed unixslayer closed 1 month ago
Hello @unixslayer , why would you need to initialize the aggregate if you want to test Service
? The behaviour seems natural as Service
has been registered in EcotoneLite.
Hi @jlabedo Aggregate as a unit of cohesion and single source of truth may be directly queried from the service. Testing Service
behavior won't be deterministic if it is a side-effect of aggregate initialization. Also if Service does a part in larger workflow, I would rather set-up my aggregate and test integration in isolation without going through whole process. Imagine the size of the test here.
Service may also be triggered in any point in time with aggregate being already persisted with specific state.
Currently Ecotone\Lite\Test\FlowTestSupport::withEventsFor
calls discardRecordedMessages
which only hides possible side-effects.
Don't know if this is more of a bug rather than a feature request.
Initializing ES aggregate generates side-effects which may be actual tested functionality. Consider following example:
Currently there is no way to properly check what actually happened because side-effect we would like to test against already happened when
Aggregate
was initialized. The only way to verify business behavior would be to expose value ofAnotherAggregate::$done
which seems a bit odd only for test purpose.Being able to initialize aggregate without additional side-effect will increase tests readability. It may also introduce testing concurrency in scenario when
Aggregate
is initialized with multiple events, publishing other than the last one may have different outcome based on business rules.