vendredi 19 octobre 2018

PowerMockito - Whitebox Get Constructor of inner class with int[] parameter

As the title mentions, I'm using PowerMockito to test a class that contains an inner private class. The inner class has a constructor that has an 'int[]' parameter. Below is the code.

final Class clazz = Whitebox.getInnerClassType(SomeClass.class, "InnerClass");
final Constructor constructor = Whitebox.getConstructor(clazz, int[].class);
final Object innerClass = constructor.newInstance(SORT_ORDER);

//This is the TARGET INNER CLASS' CONSTRUCTOR
public InnerClass(int[] sortOrder) {
    super(sortOrder);
}

The code throws

org.powermock.reflect.exceptions.ConstructorNotFoundException: Failed to lookup constructor with parameter types [ [I ] in class





Aucun commentaire:

Enregistrer un commentaire