Dagger2 replacing dependencies for testing

Viewed 36

The official dagger 2 documentation suggest to create separate component configurations for testing and reuse you modules in order to create such testing components.

However, I have the following issue: Because of wide variety of UI tests lots of dependencies needs to be changed across tests (some tests need to change caching implementation, time formatting, some repositories are replaced with mocks in order to test all possible states). As the result I end with large quantity of publish modules. Which makes creating test components very complicated. Because you need to list a dozen publish modules and add a few modules in order to supply mocks.

Is there any more elegant way how to replace a few dependencies without such complexity?

0 Answers
Related