Hi,
Because gwt's NumberFormat can not be used in jukito tests, I'm trying to inject it
with one implementation when running in the browser and another for running in unit tests and possibly in server-side code.
As far as I can tell a mock is injected and I can't force it to inject a real object.
I inject it in my presenter's constructor:
@Inject
public InputTabPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, IGwtNumberFormatSux format
)
...
I tried to manually bind it and even to forceMock it:
public abstract class AJukitoModule extends JukitoModule {
/**
* This is the test binder extending `MockingBinder` and
* implementing the view's `Binder`.
*/
static class MyTestBinder extends MockingBinder<Widget, InputTabView>
implements Binder
{
@Inject
public MyTestBinder(final MockitoMockFactory mockFactory) {
super(Widget.class, mockFactory);
}
}
@Override
protected void configureTest() {
GWTMockUtilities.disarm();
bind(Binder.class).to(AJukitoModule.MyTestBinder.class);
bind(IGwtNumberFormatSux.class).to(JavaNumberFormat.class);
// forceMock(IGwtNumberFormatSux.class);
// bindSpy(JavaNumberFormat.class);
}
}
But it never seems to call my mock method with IGwtNumberFormatSux.class :
public class MockitoMockFactory implements MockFactory {
public <T> T mock(Class<T> classToMock) {
Any hints will be much appreciated.
I attached a zip of an example maven/eclipse project demonstrating my problem.
The unit test fails because the format method returns null because it is mocked :(.
--
thanks
✝ Marius