Closed braghome closed 7 years ago
Maybe I should further explain that withExamples
function does not allow one to pass in a list of any type (primitive or regular Java collection)
@braghome Thanks for reaching out!
It looks like you might be missing a new int[]
in your example, e.g. new int[]{ 3, 4, 81, 1}
. Alternatively, you can use Arrays.asList(3, 4, 81, 1)
or a similar collection factory method. The literal { 3, 4, 81, 1}
, unfortunately, isn't valid Java 8 syntax (I wish it was!).
This works for me:
feature("find the max pair wise product", () -> {
scenarioOutline("intialise evaluation with",
(inputSample, resultOutput) -> {
given("some integers: " + asList(inputSample), () -> {
});
when ("computing the max pairwise product", () -> {
});
then("the result should be " + resultOutput, () -> {
});
},
withExamples(
example(new int[]{ 3, 4, 81, 1 }, 324L),
example(new int[]{ 5, 7, 2, 8 }, 56L)
)
);
});
@greghaskins sorry for the confusion as I was thinking of something different
public class AppTest {
/**
* @return the suite of tests being tested
*/
public static int[] intdata() {
final int[] start = { 3, 24, 12 };
return start;
}
public static void main(final String[] args) {
if (intdata()[0] == 3 && intdata()[1] == 24 && intdata()[2] == 12) {
System.out.printf("the array values are: %d, %d, %d", intdata()[0], intdata()[1], intdata()[2]);
} else {
throw new AssertionError("array was null");
}
}
}
on my sample test, I see a compilation error on my IDE