|
| Re: Mockito Spy and inner classes [message #1449276 is a reply to message #1447387] |
Tue, 21 October 2014 01:47  |
Eclipse User |
|
|
|
André Wegmüller gave me following tipp: I should check when the search for field inner is made. The form keeps references to inner-classes in private members. This search should occur after the Mockito instrumentation.
This is exactly my problem!
The AbstractForm has a constructor with a Boolean argument callInitializer. If called with false, the form needs to call the protected method callInitializer() latter on.
This is what I did:
1/ add a protected constructor in my Desktop Form:
protected DesktopForm(boolean callInitializer) throws ProcessingException {
super(callInitializer);
}
2/ add a new class in the test case to make the callInitializer() accessible and to call the new constructor
public static class P_DesktopForm extends DesktopForm {
public P_DesktopForm() throws ProcessingException {
super(false);
}
public void doCallInitializer() throws ProcessingException {
super.callInitializer();
}
}
3/ In the test case, instantiate the Desktop Form like this:
P_DesktopForm form = Mockito.spy(new P_DesktopForm());
form.doCallInitializer();
And now my test is working.
|
|
|
Powered by
FUDForum. Page generated in 0.03848 seconds