@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface Parameters
This method will be run once only.
For instance, we may wrote this code
import java.util.Arrays; import java.util.function.Function; import java.util.stream.Stream; import ch.powerunit.Parameter; import ch.powerunit.Parameters; import ch.powerunit.Test; import ch.powerunit.TestSuite; public class FunctionParameterTest<T, R> implements TestSuite { @Parameters("%1$s on %2$s expecting %3$s") public static Stream<Object[]> getDatas() { return Arrays.stream(new Object[][] { { (Function<String, Integer>) Integer::valueOf, "1", 1 } }); } @Parameter(0) public Function<T, R> function; @Parameter(1) public T input; @Parameter(2) public R expected; @Test public void testAFunction() { assertThatFunction(function, input).is(expected); } }It is also possible to indicate that each test parameter set is not applicable for each test method. This is done by using an additional, with the attribute
filter=true
. This field will be a BiFunction
receiving the test method name and the parameters and returning a boolean. (
BiFunction<String,Object[],Boolean>
). This method will be
used to check if the test method accept (or not) the parameter.
In case this annotation is used on a method from a test class annotated with
, this method is used as a way to provide
parameter to the test classes. In this case, this method must have exactly
one parameter, which will be a class annotated with
TestDelegator
.TestInterface
Stream
,
This is used on the stream to add
an object at the end of each entry (for instance the BiFunction).
public abstract String value
String.format(String, Object...)
to refer to the
parameter.
The syntax for the formatted string has change since the version
0.4.0.. At the moment, both syntax are supported, but the old one may
be removed in a future release.
String.format(String, Object...)
is used. Each parameter is available. It is here required to be careful
with the numbering of the argument ; Parameter
index are numbered
starting from 0, but in the string format the numbering start from 1. In
the easy form, the parameter can be passed with the syntax
%1$s
which for instance will use the first parameter (0
parameter), as a String.
MessageFormat.format(String, Object...)
; This syntax
is enabled when the passed string format contains the regular expression
\{[0-9]+\}
.The formatter used
for parameterized test. For version before 0.4.0.
,
The formatter used for
parameterized test, since version 0.4.0.
Copyright © 2015 Powerunit. All rights reserved.