Interface TestTemplateInvocationContextProvider

All Superinterfaces:

@API(status=STABLE, since="5.0") public interface TestTemplateInvocationContextProvider extends Extension
TestTemplateInvocationContextProvider defines the API for Extensions that wish to provide one or multiple contexts for the invocation of a @TestTemplate method.

This extension point makes it possible to execute a test 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 methods: supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext) and provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext). The former is called by the framework to determine whether this extension wants to act on a test template that is about to be executed. If so, the latter is called and must return a Stream of TestTemplateInvocationContext instances. Otherwise, this provider is ignored for the execution of the current test template.

A provider that has returned true from its supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext) method is called active. When multiple providers are active for a test template method, the Streams returned by their provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext) methods will be chained, and the test template method will be invoked using the contexts of all active providers.

Constructor Requirements

Consult the documentation in Extension for details on constructor requirements.

See Also:
TestTemplate, TestTemplateInvocationContext