Tuesday, January 26, 2016

Daggerless Dependency Injection for Testing

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.

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.