-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionTest.java
More file actions
51 lines (42 loc) · 1.55 KB
/
CollectionTest.java
File metadata and controls
51 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.froyo.junit5;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
public class CollectionTest {
@TestFactory
List<DynamicTest> dynamicTestsWithInvalidReturnType() {
return Arrays.asList(
dynamicTest("invalid return type fixed", () -> assertTrue(true))
);
}
@TestFactory
Collection<DynamicTest> dynamicTestsFromCollection() {
return Arrays.asList(
dynamicTest("1st dynamic test", () ->
assertTrue(true)),
dynamicTest("2nd dynamic test", () -> assertEquals(4, 2
* 2)));
}
@TestFactory
Iterable<DynamicTest> dynamicTestsFromIterable() {
return Arrays.asList(
dynamicTest("3rd dynamic test", () ->
assertTrue(true)),
dynamicTest("4th dynamic test", () -> assertEquals(4, 2
* 2)));
}
@TestFactory
Iterator<DynamicTest> dynamicTestsFromIterator() {
return Arrays.asList(
dynamicTest("5th dynamic test", () ->
assertTrue(true)),
dynamicTest("6th dynamic test", () -> assertEquals(4, 2
* 2))).iterator();
}
}