ClassTemplateInvocationContextProvider defines the API for
Extensions that wish to provide one or multiple contexts
for the invocation of a @ClassTemplate.
This extension point makes it possible to execute a class template in different contexts — for example, with different parameters, by preparing the test class instance differently, or multiple times without modifying the context.
This interface defines two main methods:
supportsClassTemplate and
provideClassTemplateInvocationContexts. The former is called by the
framework to determine whether this extension wants to act on a container
template that is about to be executed. If so, the latter is called and must
return a Stream of ClassTemplateInvocationContext instances.
Otherwise, this provider is ignored for the execution of the current class
template.
A provider that has returned true from its
supportsClassTemplate method is called active. When
multiple providers are active for a class template, the
Streams returned by their
provideClassTemplateInvocationContexts methods will be chained, and
the class template method will be invoked using the contexts of all active
providers.
An active provider may return zero invocation contexts from its
provideClassTemplateInvocationContexts method if it overrides
mayReturnZeroClassTemplateInvocationContexts to return
true.
Consult the documentation in Extension for details on
constructor requirements.
ClassTemplate, ClassTemplateInvocationContext
| Modifier and Type | Method and Description |
|---|---|
| public default boolean | Returns: true to allow zero contexts, false to fail
execution in case of zero contextsthe extension context for the class template
about to be invoked; never context)nullSignal that this provider may provide zero
invocation contexts for
the class template represented by the supplied |
| public Stream | Returns: aStream of ClassTemplateInvocationContext
instances for the invocation of the class template; never nullthe extension context for the class template about to be
invoked; never context)nullProvide invocation contexts
for the class template represented by the supplied |
| public boolean | Returns: true if this provider can provide invocation contextsthe extension context for the class template
about to be invoked; never context)nullDetermine if this provider supports providing invocation contexts for the
class template represented by the supplied |
| mayReturnZeroClassTemplateInvocationContexts | back to summary |
|---|---|
| public default boolean mayReturnZeroClassTemplateInvocationContexts(ExtensionContext context) Signal that this provider may provide zero
invocation contexts for
the class template represented by the supplied If this method returns
| |
| provideClassTemplateInvocationContexts | back to summary |
|---|---|
| public Stream Provide invocation contexts
for the class template represented by the supplied This method is only called by the framework if
The returned
| |
| supportsClassTemplate | back to summary |
|---|---|
| public boolean supportsClassTemplate(ExtensionContext context) Determine if this provider supports providing invocation contexts for the
class template represented by the supplied
| |