Class TestParametersValuesProvider
java.lang.Object
com.google.testing.junit.testparameterinjector.TestParametersValuesProvider
- All Implemented Interfaces:
TestParameters.TestParametersValuesProvider
public abstract class TestParametersValuesProvider
extends Object
implements TestParameters.TestParametersValuesProvider
Abstract class for custom providers of @TestParameters values.
This is a replacement for TestParameters.TestParametersValuesProvider, which is
deprecated. The difference with the former interface is that this class provides a
Context instance when invoking provideValues(com.google.testing.junit.testparameterinjector.TestParametersValuesProvider.Context).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn immutable value class that contains extra information about the context of the parameter for which values are being provided. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.protected abstract List<TestParameters.TestParametersValues>Returns a list ofTestParameters.TestParametersValuesinstances to be used as test parameters.protected booleanDeprecated.This method exists to gracefully migrate pre-v1.20 clients.
-
Constructor Details
-
TestParametersValuesProvider
public TestParametersValuesProvider()
-
-
Method Details
-
provideValues
protected abstract List<TestParameters.TestParametersValues> provideValues(TestParametersValuesProvider.Context context) throws Exception Returns a list ofTestParameters.TestParametersValuesinstances to be used as test parameters. This method is invoked exactly once for each test method.The returned list should not be empty unless
valuesListCanBeEmptyWhichMeansThatTheTestWillBeSkipped()returns true.- Throws:
Exception
-
valuesListCanBeEmptyWhichMeansThatTheTestWillBeSkipped
Deprecated.This method exists to gracefully migrate pre-v1.20 clients. Pre-v1.20, all TestParametersValuesProvider implementations were allowed to return empty lists.If this method returns true, then it is ok for theprovideValues(Context)to return an empty list.Warning: This is generally discouraged because it means that the @Test method will never be executed. This can be justified for complex tests setups that depend on external input or a test class hierarchy, but in general this indicates a bug because a reader will assume the test is run when it is not.
-
provideValues
Deprecated.This method should never be called as it will simply throw anUnsupportedOperationException.- Specified by:
provideValuesin interfaceTestParameters.TestParametersValuesProvider
-
UnsupportedOperationException.