I have a root module that installs a child module. For example:
public class RootModule extends AbstractModule {
@Override
protected void configure() {
install(new ChildModule());
}
}
public class ChildModule extends AbstractModule {
@Override
protected void configure() {
}
@Provides
@Singleton
public Bar getBar(@Named("FooImpl") Foo foo) {
return BarBuilder.withFoo(foo).build();
}
}
I was able to test the ChildModule by creating injector by binding its required dependencies (Foo.class) with Mock and testing the behavior.
To test the root Module, should I explicitly pass all the dependencies that the ChildModule consumes since the root module installs ChildModule or is there a workaround to override the installed ChildModule with a Mock?