【发布时间】:2018-11-03 17:50:38
【问题描述】:
我正在尝试将二维数组传递给参数化测试。一维数组按预期工作,但junit在第二个抱怨“索引0处的错误解析参数”。这是不支持还是我使用了错误的语法?
(junit 5.1.0)
// This is ok
static Stream<int[]> arrayStream1(){
return Stream.of( new int[] {1}, new int[] {2});
}
@ParameterizedTest
@MethodSource("arrayStream1")
void test1(int[] par) {
assertTrue(true);
}
// This is not
static Stream<int[][]> arrayStream2(){
return Stream.of( new int[][] {{1,2}}, new int[][] {{2,3}});
}
@ParameterizedTest
@MethodSource("arrayStream2")
void test2(int[][] par) {
assertTrue(true);
}
【问题讨论】:
-
对我来说听起来像是一个错误。您能否在github.com/junit-team/junit5/issues/new/choose 上打开一个问题,谢谢!在 5.4.0-SNAPSHOT 上,错误消息显示为:org.junit.jupiter.api.extension.ParameterResolutionException:在索引 0 处转换参数时出错:没有隐式转换将 [I 类型的对象转换为 [[I
-
谢谢 -- fup2 github.com/junit-team/junit5/issues/1665
标签: java testing junit junit5 parameterized-unit-test