Class TestConstructorUtils

java.lang.Object
org.springframework.test.context.support.TestConstructorUtils

public abstract class TestConstructorUtils extends Object
Utility methods for working with @TestConstructor.

Primarily intended for use within the framework.

Since:
5.2
Author:
Sam Brannen, Florian Lehmann
See Also:
  • Method Details

    • isAutowirableConstructor

      public static boolean isAutowirableConstructor(Executable executable, @Nullable PropertyProvider fallbackPropertyProvider)
      Determine if the supplied Executable is an autowirable Constructor.

      A constructor is considered to be autowirable if one of the following conditions is true.

      1. The constructor is annotated with @Autowired or @jakarta.inject.Inject.
      2. @TestConstructor is present or meta-present on the test class with autowireMode set to ALL.
      3. The default test constructor autowire mode has been set to ALL in SpringProperties or in the supplied fallback PropertyProvider.
      Parameters:
      executable - an Executable for a test class
      fallbackPropertyProvider - fallback property provider used to look up the value for "spring.test.constructor.autowire.mode" if no such value is found in SpringProperties; may be null if there is no fallback support
      Returns:
      true if the executable is an autowirable constructor
      Since:
      6.2.13
      See Also: