Interface ClassTemplateInvocationContextProvider

All Superinterfaces:
Extension

@API(status=EXPERIMENTAL, since="5.13") public interface ClassTemplateInvocationContextProvider extends Extension
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(org.junit.jupiter.api.extension.ExtensionContext) and provideClassTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext). 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(org.junit.jupiter.api.extension.ExtensionContext) method is called active. When multiple providers are active for a class template, the Streams returned by their provideClassTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext) 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(org.junit.jupiter.api.extension.ExtensionContext) method if it overrides mayReturnZeroClassTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext) to return true.

Constructor Requirements

Consult the documentation in Extension for details on constructor requirements.

Since:
5.13
See Also: