I’ve couple of questions when trying to use hilt for testing in a multi-module project:
- Say I’ve a feature module which declared some interface and its classes depend upon that interface. The implementation of this interface is provided in the
:app
module (or any module below:feature
) which is not available to feature module. How can I write tests for feature module in the feature module itself? As feature module don’t have binding for that interface, it throws missing binding error. Sure I can provide fake/mock dependencies for them, but what if say I’ve 50 such interfaces whose bindings exist below that feature module? Providing fakes doesn’t look scalable here - How to replace only a single dependency in other module?
- If we need to use
@UninstallModules
for #2, how will you do so when the original dagger module isinternal
?
I've tried using local dagger module inside @HiltAndroidTest
annotated class, but without @UninstallModules
, it doesn't work. And I don't have access to original module since it was internal
to that gradle module