I am using very simple and likely very common scenario. Here is my sample dependency:
public class MyDependency {
@Inject
public MyDependency(...) {
...
}
}
I am not listing the above in any module (that is, there is no @Provides
for MyDependency).
My sample use case goes like this:
public class ThePresenter {
@Inject
MyDependency myDependency;
public ThePresenter() {
App.getInstance().getAppComponent().inject(this);
}
}
Now I'd like to mock my dependency in unit tests. I don't want to use modules overrides (that would mean I have to add @Provides for all my dependencies marked with @Inject constructors), test components etc. Is there any alternative but standard and simple approach for the problem?