Test multiple Commands in one FixtureConfiguration

Hi!

I would like to have a Test like:

@Test
public void myAxon3Testmethod() {

   testFixture
         .given(
               new MyEventToDefineTheFixture()
         ).when(
               new MyFirstCommand(),
               new MySecondCommand()
         ).expectEvents(
               new MyExpectedEvent()
         );
}

So I would like to describe what should happen if 2 certain commands are executed.
As a workaround I could:

  1. Convert one command into an event or

  2. Create a special Test-Command that takes the two commands as a payload.

In some cases it’s more natural to define 2 commands instead of describing what has happend bei converting them into events.
Or am I missing something?

Greetings,
Dirk

Hi Dirk,

you can’t get more than one command in the “when”, however, you can provide commands as an alternative to events in the “given” part.

In your case:

@Test
public void myAxon3Testmethod() {

testFixture
.given(
new MyEventToDefineTheFixture()
).andGivenCommands(
new MyFirstCommand()
).when(
new MySecondCommand()

).expectEvents(
new MyExpectedEvent()
);
}

The expressed expectations are always matched with the results of the “when” phase.

Cheers,

Allard

Hi Allard,

great - I missed the “andGivenCommands” Part. That is exactly what I need.
Thanks for your great work!

cu,
Dirk

Ah ok - now I know why I missed it. This feature is on the master but not existing in Version 3.0.7 in the TestExecutor Class.
I switched to Version 3.1 which contained your mentioned feature ;-).