Interface ProvidePropertyInstanceHook

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

@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.

  • Field Details

  • Method Details

    • 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!

      Parameters:
      containerClass - The container class which runs the test
      Returns:
      an object that must be assignable to containerClass
      Throws:
      Throwable