This answer has been very helpful in pointing me in the right direction.
However, things are not entirely clear to me.
Please, can somebody explain me a bit better:
- Option 1: Override bindings by subclassing modules
That would mean that I actually will have to change the production code so that I can inject the mock dependency?
Example:
@Test
public void testFoo(){
MyClass class=new MyClass();
assertTrue(class.doStuff());
}
public class MyClass(){
@Inject
private Dependency dependency;
public MyClass(){}
MyDaggerComponent.builder().foo(new MockDependency).build.inject(MyClass.this);
}
This would mean that I would need to change MyClass to pass the mock module,
correct?
- Option 2: Separate component configurations
Would that mean that I would have 2 Gradle productFlavors, - one containing the production Module and Component, - one containing the mocks.
correct?
Thanks for your help!