I\'m attempting to test a class with a number of private classes (yes, I know this is generally considered poor practice for testability, but this question is not in regards to
You can mock it like this:
InnerClassType innerClass = (InnerClassType) Mockito.mock(
Class.forName(EnclosingClass.class.getName() + "$InnerClass")
);
You should be able to move past your ConstructorNotFoundExeception via the following mods to your first effort:
Class clazz = Whitebox.getInnerClassType(EnclosingClass.class, "InnerClass");
Constructor constructor = Whitebox.getConstructor(clazz, EnclosingClass.class);
InnerClassType innerClass = (InnerClassType) constructor.newInstance(new EnclosingClass());
Since your inner class is not static, it implicitly expects a "this" reference from the outer class. Using this method, looks like you have to get explicit with it.