Daggerless Dependency Injection for Testing

0 ratings
I want this!

Daggerless Dependency Injection for Testing

Chiu-Ki Chan
0 ratings

Dependency injection is a design pattern. Libraries such as Dagger help you implement it, but you can also do it yourself.

In this course we will refactor a sample app to use dependency injection, and add Espresso testing after that.

Table of content

1 Why Dependency Injection

    1.1 Dependency via Constructor

    1.2 No Libraries Necessary

2 The Sample App

    2.1 Get Battery Level

    2.2 Extract BatteryReader

3 Injecting Dependency

    3.1 Provide BatteryReader via Injection

    3.2 InjectBatteryReader

    3.3 MockInjection

    3.4 Mock Application via Custom Test Runner

    3.5 Mock BatteryReader During Testing

4 Espresso Testing

    4.1 Provide Mocks

    4.2 Set State and Verify

    4.3 Summary

5 To Dagger or not Dagger

    5.1 Why Dagger

    5.2 Performance

    5.3 Dependency Injection Your Way

6 Afterword

I want this!
260 KB
20 pages