Albert-Gao / DaggerAndroidKotlinExample

A minimal setup for using dagger-android with Kotlin to setup application wide and activity wide dependencies.
15 stars 7 forks source link

Maintainance difficulty #1

Closed GangChenGoCode closed 4 years ago

GangChenGoCode commented 4 years ago

Thanks first of all for the mocking idea. However I found thatthe Activities/FragmentsBindingModuleForTest has to be synced up with the Activities/FragmentsBindingModule, saying if one project has dozens of Activities/Fragments, the maintenance effort for keeping these modules in sync manually is a big. Do you have any idea to not duplicate code not wanted but only providing specific Activities/Fragments that need to be injected with mocked objects?

Thanks

Albert-Gao commented 4 years ago

Thanks for the question. But I don't do any native Android dev anymore. So really can't help much here. :( Really sorry.

The problem here is that you have to recreate the whole dagger context when doing the testing, so the app can get up and running. So that duplication seems to be inevitable. I could be wrong because I am a React native dev now...

Is this something can be solved at the test lib layer? For example, dagger2 should be popular in the Android dev community, so there are testing libs which should work with dagger2 to make this part easier?

GangChenGoCode commented 4 years ago

Thanks for your answer, just one discussion is appreciated! I don't think version could help but, I think this can be reduced if using some inheritance. Will let you know if it work.