Package org.axonframework.test.fixture
Class AxonTestFixture
java.lang.Object
org.axonframework.test.fixture.AxonTestFixture
- All Implemented Interfaces:
AxonTestPhase.Setup
Fixture for testing Axon Framework application. The fixture can be configured to use your whole application
configuration or just a portion of that (single module or component). The fixture allows the execution of
given-when-then style.
- Since:
- 5.0.0
- Author:
- Allard Buijze, Mateusz Nowak, Mitchell Herrijgers, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAllow customizing the fixture setup. -
Constructor Summary
ConstructorsConstructorDescriptionAxonTestFixture(AxonConfiguration configuration, AxonTestFixture.Customization customization) Creates a new fixture. -
Method Summary
Modifier and TypeMethodDescriptiongiven()Transition to the Given phase to define the initial state of the system before testing.voidstop()Stops the fixture, releasing any active resources, like registered handlers or pending event processing tasks.when()Transition directly to the When phase, skipping the Given phase, which implies no prior state.static AxonTestFixturewith(ApplicationConfigurer configurer) Creates a new fixture.static AxonTestFixturewith(ApplicationConfigurer configurer, UnaryOperator<AxonTestFixture.Customization> customization) Creates a new fixture.
-
Constructor Details
-
AxonTestFixture
public AxonTestFixture(@Nonnull AxonConfiguration configuration, @Nonnull AxonTestFixture.Customization customization) Creates a new fixture.- Parameters:
configuration- The fixture will use the configuration to obtain components needed for test execution.customization- A function that allows to customize the fixture setup.
-
-
Method Details
-
with
Creates a new fixture.- Parameters:
configurer- The fixture will use the configuration build from the given configurer to obtain components needed for test execution.- Returns:
- A new fixture instance
-
with
public static AxonTestFixture with(@Nonnull ApplicationConfigurer configurer, @Nonnull UnaryOperator<AxonTestFixture.Customization> customization) Creates a new fixture.- Parameters:
configurer- The fixture will use the configuration build from the given configurer to obtain components needed for test execution.customization- A function that allows to customize the fixture setup.- Returns:
- A new fixture instance
-
given
Description copied from interface:AxonTestPhase.SetupTransition to the Given phase to define the initial state of the system before testing.- Specified by:
givenin interfaceAxonTestPhase.Setup- Returns:
- A
AxonTestPhase.Giveninstance that allows defining the initial state.
-
when
Description copied from interface:AxonTestPhase.SetupTransition directly to the When phase, skipping the Given phase, which implies no prior state.- Specified by:
whenin interfaceAxonTestPhase.Setup- Returns:
- A
AxonTestPhase.Wheninstance that allows executing the test.
-
stop
public void stop()Description copied from interface:AxonTestPhase.SetupStops the fixture, releasing any active resources, like registered handlers or pending event processing tasks.- Specified by:
stopin interfaceAxonTestPhase.Setup
-