mardi 13 juin 2017

Reflection Exception in parameterized JUnit test using array parameter

I tried to setup a parameterized test in JUnit 4.11 which generates a single parameter. This parameter, however, needs to be an array itself.

The expected behavior for the following code snippet would be that test() is run twice while arguments holds an array {"test1", "test2"} in the first run and an array {"test3", "test4"} in the second run.

@RunWith(Parameterized.class)
public class Test {

    @Parameter
    private String[] arguments;

    @Parameters
    public static Iterable<Object[]> data() {
        return Arrays.asList(
                new Object[][]{
                    {new String[] {"test1","test2"}},
                    {new String[] {"test3","test4"}}
                }
        );  
    }

    @Test
    public void test() {
        fail();
    }
}

When I execute the test, however, a SlowCheckMemberAccess Exception is thrown. Google delivered no results for that kind of problem.

Can anyone explain what is going wrong here?





Aucun commentaire:

Enregistrer un commentaire