I got this to work. My problem was that I was not using the JukitoRunner (we use Play framework so I don't think I can).
I had to do some sneaky stuff to get this to do what I want. I created my own module that exted JukitoModule and sadly the constructor for BindingsCollector is package protected so I had to put this class in an org.jukito package. Here's my custom module that does what I needed.
*
* I had to put this in the org.jukito package because the Constructor for BindingsCollector is
* package protected.
*/
public class SandboxTestModule extends JukitoModule {
@Override
protected void configureTest() {
bind(MainView.Presenter.class).to(MainPresenter.class);
}
@Provides
@Singleton
MainView mainView() {
MainView view = org.mockito.Mockito.mock(MainView.class);
HasWidgets contentPanel = org.mockito.Mockito.mock(HasWidgets.class);
org.mockito.Mockito.when(view.getContentPanel()).thenReturn(contentPanel);
return view;
}
// This is mimicking what JukitoTestRunner does so we can test w/o the runner.
public SandboxTestModule() {
BindingsCollector collector = new BindingsCollector(this);
collector.collectBindings();
setBindingsObserved(collector.getBindingsObserved());
}
}
If JukitoModule's binding intialization was moved out of JukitoRunner and instead was a method in JukitoModule than this would have been easier. Something like this:
BindingsCollector collector = new BindingsCollector(this);
collector.collectBindings();
setBindingsObserved(collector.getBindingsObserved());
}
Then JukitoRunner would change:
BindingsCollector collector = new BindingsCollector(testModuleForCollection);
collector.collectBindings();
jukitoModule.setBindingsObserved(collector.getBindingsObserved());
to:
jukitoModule.initBindings();