- java.lang.Object
-
- org.junit.jupiter.params.ParameterizedTestExtension
-
- All Implemented Interfaces:
Extension
,TestTemplateInvocationContextProvider
class ParameterizedTestExtension extends java.lang.Object implements TestTemplateInvocationContextProvider
- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
ARGUMENT_MAX_LENGTH_KEY
private static java.lang.String
DEFAULT_DISPLAY_NAME
(package private) static java.lang.String
DISPLAY_NAME_PATTERN_KEY
private static java.lang.String
METHOD_CONTEXT_KEY
-
Constructor Summary
Constructors Constructor Description ParameterizedTestExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.stream.Stream<? extends Arguments>
arguments(ArgumentsProvider provider, ExtensionContext context)
private java.lang.Object[]
consumedArguments(java.lang.Object[] arguments, ParameterizedTestMethodContext methodContext)
private TestTemplateInvocationContext
createInvocationContext(ParameterizedTestNameFormatter formatter, ParameterizedTestMethodContext methodContext, java.lang.Object[] arguments, int invocationIndex)
private ParameterizedTestNameFormatter
createNameFormatter(ExtensionContext extensionContext, java.lang.reflect.Method templateMethod, ParameterizedTestMethodContext methodContext, java.lang.String displayName, int argumentMaxLength)
private ExtensionContext.Store
getStore(ExtensionContext context)
private ArgumentsProvider
instantiateArgumentsProvider(java.lang.Class<? extends ArgumentsProvider> clazz)
java.util.stream.Stream<TestTemplateInvocationContext>
provideTestTemplateInvocationContexts(ExtensionContext extensionContext)
Provide invocation contexts for the test template method represented by the suppliedcontext
.boolean
supportsTestTemplate(ExtensionContext context)
Determine if this provider supports providing invocation contexts for the test template method represented by the suppliedcontext
.
-
-
-
Field Detail
-
METHOD_CONTEXT_KEY
private static final java.lang.String METHOD_CONTEXT_KEY
- See Also:
- Constant Field Values
-
ARGUMENT_MAX_LENGTH_KEY
static final java.lang.String ARGUMENT_MAX_LENGTH_KEY
- See Also:
- Constant Field Values
-
DEFAULT_DISPLAY_NAME
private static final java.lang.String DEFAULT_DISPLAY_NAME
- See Also:
- Constant Field Values
-
DISPLAY_NAME_PATTERN_KEY
static final java.lang.String DISPLAY_NAME_PATTERN_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
supportsTestTemplate
public boolean supportsTestTemplate(ExtensionContext context)
Description copied from interface:TestTemplateInvocationContextProvider
Determine if this provider supports providing invocation contexts for the test template method represented by the suppliedcontext
.- Specified by:
supportsTestTemplate
in interfaceTestTemplateInvocationContextProvider
- Parameters:
context
- the extension context for the test template method about to be invoked; nevernull
- Returns:
true
if this provider can provide invocation contexts- See Also:
TestTemplateInvocationContextProvider.provideTestTemplateInvocationContexts(org.junit.jupiter.api.extension.ExtensionContext)
,ExtensionContext
-
provideTestTemplateInvocationContexts
public java.util.stream.Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext extensionContext)
Description copied from interface:TestTemplateInvocationContextProvider
Provide invocation contexts for the test template method represented by the suppliedcontext
.This method is only called by the framework if
TestTemplateInvocationContextProvider.supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext)
previously returnedtrue
for the sameExtensionContext
; this method is allowed to return an emptyStream
but notnull
.The returned
Stream
will be properly closed by callingBaseStream.close()
, making it safe to use a resource such asFiles.lines()
.- Specified by:
provideTestTemplateInvocationContexts
in interfaceTestTemplateInvocationContextProvider
- Parameters:
extensionContext
- the extension context for the test template method about to be invoked; nevernull
- Returns:
- a
Stream
ofTestTemplateInvocationContext
instances for the invocation of the test template method; nevernull
- See Also:
TestTemplateInvocationContextProvider.supportsTestTemplate(org.junit.jupiter.api.extension.ExtensionContext)
,ExtensionContext
-
instantiateArgumentsProvider
private ArgumentsProvider instantiateArgumentsProvider(java.lang.Class<? extends ArgumentsProvider> clazz)
-
getStore
private ExtensionContext.Store getStore(ExtensionContext context)
-
createInvocationContext
private TestTemplateInvocationContext createInvocationContext(ParameterizedTestNameFormatter formatter, ParameterizedTestMethodContext methodContext, java.lang.Object[] arguments, int invocationIndex)
-
createNameFormatter
private ParameterizedTestNameFormatter createNameFormatter(ExtensionContext extensionContext, java.lang.reflect.Method templateMethod, ParameterizedTestMethodContext methodContext, java.lang.String displayName, int argumentMaxLength)
-
arguments
protected static java.util.stream.Stream<? extends Arguments> arguments(ArgumentsProvider provider, ExtensionContext context)
-
consumedArguments
private java.lang.Object[] consumedArguments(java.lang.Object[] arguments, ParameterizedTestMethodContext methodContext)
-
-