Reputation: 360
I'm having this method
@TestFactory
Stream<DynamicTest> dynamicTestsFromStream() throws IOException {
initialize();
return Stream.of(core).map(
str -> DynamicTest.dynamicTest("test" + str.toString(), () -> { Just for Testing > Assert.assertTrue(false); }));
}
My core
Array contains Elements of Type Tuple4
. Tuple4(String a, String b, String c, String d)
.
When I'm trying to adress the name (i want String c
) I get an error, and in the current example my
result for str
is:Tuple4@4d50efb8, Tuple4@7e2d773b, Tuple4@2173f6d9
Can someone tell me how I can adress the right index for str? since get(int)
won't work, because I can't get the current position?
EDIT
When I put Stream.of("A","B","C").map(...);
The test is given the right names "test A" ...
So how can I give stream.of()
an Array(Object) to name the tests?
Upvotes: 1
Views: 159
Reputation: 51050
With Stream.of(SomeType[])
you run the risk of getting a stream containing just a single element, namely the array. Use Arrays::stream
instead.
Assuming core
is of type Tuple4[]
(if it is not, please include the actual type in the question), you can do as follows:
@TestFactory
Stream<DynamicTest> dynamicTestsFromStream() throws IOException {
initialize();
return Arrays.stream(core) // Stream<Tuple4>
.map(tuple -> DynamicTest.dynamicTest(
"test " + tuple.c,
() -> { Assert.assertTrue(false); }
));
}
Upvotes: 2