https://kotlinlang.org logo
#dagger
Title
a

Ahmed Ibrahim

09/25/2020, 11:54 AM
I have several test classes that are annotated by
HiltAndroidTest
and they have
UninstallModules
with the same set of modules to uninstall. If I add or remove an extra module to uninstall, I have to cascade the changes to the rest. Is there a way to avoid repeating myself with Hilt or do I need to file a feature request for that? What I tried and didn't work (inspired by Spring Boot TestComponent annotation)
Copy code
@UninstallModules(SearchModule::class, SearchResultsModule::class, DestinationsSearchModule::class)
@HiltAndroidTest
internal class MonthsFragmentTest
Tried writing an annotation that combines them
Copy code
@UninstallModules(
    SearchModule::class,
    SearchResultsModule::class,
    DestinationsSearchModule::class
)
@kotlin.annotation.Target
annotation class UninstallSearchProductionModules
and tried replacing them
Copy code
@UninstallSearchProductionModules
@HiltAndroidTest
internal class MonthsFragmentTest
a

allan.conda

09/26/2020, 2:02 AM
Yeah it’s a limitation for now, there’s an existing issue in GitHub if you try to find it
a

Ahmed Ibrahim

09/26/2020, 8:31 AM
Thanks for pointing out. In case someone is interested to read the issue. https://github.com/google/dagger/issues/1923