Class AxonTestFixture

java.lang.Object
org.axonframework.test.fixture.AxonTestFixture
All Implemented Interfaces:
AxonTestPhase.Setup

public class AxonTestFixture extends Object implements 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
  • 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

      public static AxonTestFixture with(@Nonnull ApplicationConfigurer configurer)
      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

      public AxonTestPhase.Given given()
      Description copied from interface: AxonTestPhase.Setup
      Transition to the Given phase to define the initial state of the system before testing.
      Specified by:
      given in interface AxonTestPhase.Setup
      Returns:
      A AxonTestPhase.Given instance that allows defining the initial state.
    • when

      public AxonTestPhase.When when()
      Description copied from interface: AxonTestPhase.Setup
      Transition directly to the When phase, skipping the Given phase, which implies no prior state.
      Specified by:
      when in interface AxonTestPhase.Setup
      Returns:
      A AxonTestPhase.When instance that allows executing the test.
    • stop

      public void stop()
      Description copied from interface: AxonTestPhase.Setup
      Stops the fixture, releasing any active resources, like registered handlers or pending event processing tasks.
      Specified by:
      stop in interface AxonTestPhase.Setup