@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("{0} on {1} expecting {2}")
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.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
The formatter usedCopyright © 2014. All rights reserved.