Shouldn't GivenWhenThenTestFixture support any givenCommands?

During execution of “when”, detectIllegalStateChanges() fails with “java.lang.AssertionError: The aggregate used in this fixture was initialized with an identifier different than the one used to load it” because previously given command targeted different aggregate root.

I would like to have possibility to create whole test environment (create several AR if necessary) by using givenCommands. Currently it is not possible.

I believe this feature would not be useful in purely event sourced environment, but it could be useful when using HybridJpaRepository.

What do you think?
Pawel

Could you please show some example code? I don’t understand what benefit givenCommands(…) would bring - if anything it will add unfortunate coupling between your tests because when the logic in one command-handler changes, for example a validation change, you risk breaking all of your existing tests that provide that command in the givenCommands(…)

Hi,

the fixtures were never designed to test multiple aggregates at the same time. Nor to perform integration tests. They are merely unit tests that use functional input and output to make them independent of implementation choices.

If you want to test more than just a single aggregate, I would suggest using a proper integration test.

Note that ‘givenCommands’ is merely a shortcut for ‘givenEvents’ where a single command can lead to a large number of events (making the test easier to configure). Use it with caution.

Cheers,

Allard