I have written many articles about using Dagger to inject mocks into tests to remove external dependencies. But many people don't want to use Dagger, for a variety of reasons.
@chiuki I like your blog post on Espresso. Is there a way to inject mocks into an activity in Espresso tests without using Dagger?
— Mohit S (@heyitsmohit) January 18, 2016
Dependency injection is a design pattern. The libraries are there to help you, but if you prefer you can definitely implement it yourself.
Remember I said I want to write a book on Espresso, but only if there is enough demand? For this particular topic there is definitely a lot of demand, so I went ahead and wrote a primer: Daggerless Dependency Injection for Testing.
It shows you how to how to set up your Android project and implement dependency injection from first principles. You will be refactoring a sample app to learn how to extract dependencies for injection purposes. And of course there are some Espresso tests as well.
Get it here: https://gum.co/DaggerlessDITesting.