Interface ContextCustomizerFactory

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ContextCustomizerFactory
Factory for creating ContextCustomizers.

Factories are invoked after ContextLoaders have processed context configuration attributes but before the MergedContextConfiguration is created.

By default, the Spring TestContext Framework will use the SpringFactoriesLoader mechanism for loading default factories configured in all META-INF/spring.factories files on the classpath.

As of Spring Framework 6.1, it is also possible to register factories declaratively via the @ContextCustomizerFactories annotation.

Since:
4.3
Author:
Phillip Webb, Sam Brannen
See Also:
  • Method Details

    • createContextCustomizer

      @Nullable ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes)
      Create a ContextCustomizer that should be used to customize a ConfigurableApplicationContext before it is refreshed.
      Parameters:
      testClass - the test class
      configAttributes - the list of context configuration attributes for the test class, ordered bottom-up (i.e., as if we were traversing up the class hierarchy or enclosing class hierarchy); never null or empty
      Returns:
      a ContextCustomizer or null if no customizer should be used