Fields or step parameters can be annotated with
IteratedParameter
. Parameters are injected by tapir at Test execution
runtime. There are several ways how to provide the data:
- unparameterized @Parameter: You have to implement a method which's name is derived from the field / parameter name in
the test class which returns an
Iterable
of the parameter
value()
or method()
: You have to implement a method with the given name in the test class which returns
an Iterable
of the parameter
providerClass()
: The given providerClass has to provide a method which returns the parameter. The method name
can be derived from the field / parameter name or explicitly specified by using value()
/method()
.
For every element in the returned
Iterable
the test class or step is executed. As you can annotate as many fields and
step parameters as you like tapir executes them by using the cartesian product.
Example:
@TestClass
class MyTest {
@IteratedParameter String stringParameter
@IteratedParameter Integer integerParameter
@Step def step1(@IteratedParameter String stepStringParameter, @IteratedParameter Integer stepIntegerParameter) {
}
override stringParameterParameter() {
#["a", "b"]
}
override integerParameterParameter() {
#[1, 2]
}
override step1StepStringParameterParameter() {
#["y", "z"]
}
override step1StepIntegerParameterParameter() {
#[8, 9]
}
}
step1 will be executed 16 times:
stringParameter |
integerParameter |
stepStringParameter |
stepIntegerParameter |
a | 1 | y | 8 |
a | 1 | y | 9 |
a | 1 | z | 8 |
a | 1 | z | 9 |
a | 2 | y | 8 |
a | 2 | y | 9 |
a | 2 | z | 8 |
a | 2 | z | 9 |
b | 1 | y | 8 |
b | 1 | y | 9 |
b | 1 | z | 8 |
b | 1 | z | 9 |
b | 2 | y | 8 |
b | 2 | y | 9 |
b | 2 | z | 8 |
b | 2 | z | 9 |
If a test class or step should not be executed multiple times based on the parameter value, please consult
Parameter
.