Schnittstelle ProvidePropertyInstanceHook

Alle Superschnittstellen:
LifecycleHook
Funktionsschnittstelle:
Dies ist eine funktionale Schnittstelle, die somit als Zuweisungsziel für einen Lambdaausdruck oder eine Methodenreferenz verwendet werden kann.

@API(status=EXPERIMENTAL, since="1.6.0") @FunctionalInterface public interface ProvidePropertyInstanceHook extends LifecycleHook
Implement this hook to override behaviour that provides the test instance for each property try. Per default the only accessible constructor of the container class is invoked, with all parameters being resolved through applicable ResolveParameterHook hooks.

This hook can only be used in simple cases, since parameter resolution is currently unavailable to implementors.

Caveat: Only one hook per property method is possible.

  • Felddetails

  • Methodendetails

    • provide

      Object provide(Class<?> containerClass) throws Throwable
      Create the test instance for running a property or example. You may want to override the default call if provision does something else than plain instance creation from class.

      This method will be called exactly once per property. All tries share the same instance!

      Parameter:
      containerClass - The container class which runs the test
      Gibt zurück:
      an object that must be assignable to containerClass
      Löst aus:
      Throwable