Package org.springframework.test.context.support

# 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:
  - `TestConstructor`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass)`
Determine if the supplied constructor for the given test class is autowirable.
`static boolean`
`isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass, PropertyProvider fallbackPropertyProvider)`
Determine if the supplied constructor for the given test class is autowirable.
`static boolean`
`isAutowirableConstructor(Executable executable, Class<?> testClass)`
Determine if the supplied executable for the given test class is an autowirable constructor.
`static boolean`
`isAutowirableConstructor(Executable executable, Class<?> testClass, PropertyProvider fallbackPropertyProvider)`
Determine if the supplied executable for the given test class is an autowirable constructor.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### isAutowirableConstructor

public static boolean isAutowirableConstructor(Executable executable, Class<?> testClass)
Determine if the supplied executable for the given test class is an autowirable constructor.

This method delegates to `isAutowirableConstructor(Executable, Class, PropertyProvider)` will a value of `null` for the fallback `PropertyProvider`.

Parameters:
  `executable` - an executable for the test class
  `testClass` - the test class
Returns:
  `true` if the executable is an autowirable constructor
See Also:
  - `isAutowirableConstructor(Executable, Class, PropertyProvider)`

### isAutowirableConstructor

public static boolean isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass)
Determine if the supplied constructor for the given test class is autowirable.

This method delegates to `isAutowirableConstructor(Constructor, Class, PropertyProvider)` will a value of `null` for the fallback `PropertyProvider`.

Parameters:
  `constructor` - a constructor for the test class
  `testClass` - the test class
Returns:
  `true` if the constructor is autowirable
See Also:
  - `isAutowirableConstructor(Constructor, Class, PropertyProvider)`

### isAutowirableConstructor

public static boolean isAutowirableConstructor(Executable executable, Class<?> testClass, @Nullable PropertyProvider fallbackPropertyProvider)
Determine if the supplied executable for the given test class is an autowirable constructor.

This method delegates to `isAutowirableConstructor(Constructor, Class, PropertyProvider)` if the supplied executable is a constructor and otherwise returns `false`.

Parameters:
  `executable` - an executable for the test class
  `testClass` - the test class
  `fallbackPropertyProvider` - fallback property provider used to look up the value for `TestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME` if no such value is found in `SpringProperties`
Returns:
  `true` if the executable is an autowirable constructor
Since:
  5.3
See Also:
  - `isAutowirableConstructor(Constructor, Class, PropertyProvider)`

### isAutowirableConstructor

public static boolean isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass, @Nullable PropertyProvider fallbackPropertyProvider)
Determine if the supplied constructor for the given test class is autowirable.

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

1. The constructor is annotated with `@Autowired`, `@jakarta.inject.Inject`, or `@javax.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` (see `TestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_MODE_PROPERTY_NAME`).

Parameters:
  `constructor` - a constructor for the test class
  `testClass` - the test class
  `fallbackPropertyProvider` - fallback property provider used to look up the value for the default test constructor autowire mode if no such value is found in `SpringProperties`
Returns:
  `true` if the constructor is autowirable
Since:
  5.3