可以将集合/可迭代对象/流传递到@ParamterizedTests 中吗?

Can collections / iterables / streams be passed into @ParamterizedTests?

在 Junit5 5.0.0 M4 中我可以这样做:

@ParameterizedTest
@MethodSource("generateCollections")
void testCollections(Collection<Object> collection) {
  assertOnCollection(collection);
}

private static Iterator<Collection<Object>> generateCollections() {
  Random generator = new Random();

  // We'll run as many tests as possible in 500 milliseconds.
  final Instant endTime = Instant.now().plusNanos(500000000);
  return new Iterator<Collection<Object>>() {
    @Override public boolean hasNext() {
      return Instant.now().isBefore(endTime);
    }

    @Override public Collection<Object> next() {
      // Dummy code
      return Arrays.asList("this", "that", Instant.now());
    }
  };
}

或者任何数量的其他东西最终以一种或另一种类型的集合被传递到我的@ParameterizedTest。这不再有效:我现在收到错误

org.junit.jupiter.api.extension.ParameterResolutionException:
  Error resolving parameter at index 0

我一直在查看最近对 SNAPSHOT 的提交,我发现该区域发生了一些变化,但我看不到任何明显改变的东西。

这是故意改变的吗?我会在 JUnit5 开发人员频道上询问这个问题,但我找不到。这本身并不是错误:传递集合不是记录的功能。

如果这是有意更改,那么这肯定是 @TestFactory...

的用例

https://github.com/junit-team/junit5/issues/872

下一个快照构建应该修复回归。