I have an Android app that uses Dagger 2 for dependency injection. I am also using the latest gradle build tools that allow a build variant for unit testing and one for inst
If you are using dagger2 with Android, you can use app flavours for providing mocking resources.
See here for a demo of flavours in mock testing(without dagger): https://www.youtube.com/watch?v=vdasFFfXKOY
This codebase has an example: https://github.com/googlecodelabs/android-testing
In your /src/prod/com/yourcompany/Component.java you provide your production components.
In your /src/mock/com/yourcompany/Component.java you provide your mocking components.
This allows you create builds of your app with or without mocking. It also allows parallel development (backend by one team, frontend app by another team), you can mock until api methods are avilable.
How my gradle commands look (its a Makefile):
install_mock:
./gradlew installMockDebug
install:
./gradlew installProdDebug
test_unit:
./gradlew testMockDebugUnitTest
test_integration_mock:
./gradlew connectedMockDebugAndroidTest
test_integration_prod:
./gradlew connectedProdDebugAndroidTest