Espresso testing with Dagger 2 and custom scopes

拜拜、爱过 提交于 2019-12-06 11:23:07

The approach that I took at the end was to create a custom AndroidJUnitRunner as described here and to create Components/Modules which provide mocks for each app feature, including the Application module check Google doc for best practices. Furthermore, each activity under test has to be overridden to inject the mocks (just the method that injects the mocked dependencies).

In order to keep the main app manifest clean, the overridden test activities are declared in a debug manifest. Hope this approach helps people with a similar to my Dagger 2 setup to do their testing with Espresso and Dagger 2.

Have a rock ’n’ roll day!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!