public Map<String, List<Tuple4>> buildTestcases(ArrayList<Tuple4> list){
Map<String, List<Tuple4>> map = new LinkedHashMap<String, List<Tuple4>>();
for(Tuple4 element: list){
String[] token = element.c.split("\\s");
if (!map.containsKey(token[1])) {
map.put(token[1], new ArrayList<Tuple4>());
}
map.get(token[1]).add(element);
}
System.out.println(map);
return map;
}
public Tuple4(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
我正在为某些匹配的测试用例构建一个测试套件。现在我想将它转换为一个数组,因为我正在从中构造一个 dynamicTest :
return Stream.of(<Array needed>).map(
tuple -> DynamicTest.dynamicTest("Testcase: ", () -> { ... }
有没有办法将它转换为像Object[String][Tuple4]
编辑:
好的,现在我有这段代码:
`@TestFactory public Stream dynamicTuple4TestsFromStream() throws IOException{ initialize();
return map.entrySet().stream()
.flatMap(entry ->
entry.getValue().stream()
.map(s -> new AbstractMap.SimpleEntry<>(entry.getKey(), s)))
.forEach(e -> DynamicTest.dynamicTest("Testcase: " +e.getKey(), () -> {
tester = new XQueryTester(e.getValue().a, e.getValue().b);
if(e.getValue().c.contains("PAY")){
Assert.assertTrue(tester.testBody(e.getValue().c,e.getValue().d));
}
})); }`
我得到了这个例外:
incompatible types: void cannot be converted to java.util.stream.Stream<org.junit.jupiter.api.DynamicTest>
如何/为什么?