DaggerMock
DaggerMock copied to clipboard
Why is DaggerMock trying to mock all objects in the graph?
Mockito cannot mock/spy because :
- final class
I have an object that is being passed into a subcomponent with @BindsInstance. DaggerMock is trying to mock this object even though I don't want to mock it in tests, and this is causing my test to crash.
Are you sure the error is on the object used in a @BindsInstance annotated method?
However if you are using DaggerMock in a Kotlin project you should consider using something to avoid problems with final methods/classes. More info here: https://github.com/fabioCollini/DaggerMock/#kotlin-support
@Subcomponent.Builder
interface Builder {
@BindsInstance
Builder activity(AppCompatActivity activity);
// Everything breaks when I add the following.
@BindsInstance
Builder lifecycleEvents(SomeFinalClassFromALibraryICantMakeOpen object);
ActivityComponent build();
}
I'm not trying to mock this final class in my UI tests, so why does it matter if the object being bound is final or not?
mock-maker-inline does not seem to work with androidTests.