samedi 3 novembre 2018

Can multidimensional arrays be passed via @MethodSource (junit 5.1)?

I'm trying to pass two-dimensional arrays to a parameterized test. The one-dimensional array works as expected, but junit complains on the second with "Error resolving parameter at index 0". Is this not supported or am I using the wrong syntax?

(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<byte[][]> arrayStream2(){
    return Stream.of( new byte[][] 1, new byte[][] 2);
}

@ParameterizedTest
@MethodSource("arrayStream2")
void test2(int[][] par) {
    assertTrue(true);
}   

Aucun commentaire:

Enregistrer un commentaire