Sign in Go Pro

Dagger 2 (retired)

Testing with Mockito with a TestComponent

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next


Course Retired

This course has been replaced by a much more up to date version: Dependency Injection with Dagger 2


In this Lesson you will learn:

  • How to structure your app so that you can enable testing with Dagger 2 and Espresso
  • How to create a Dagger 2 TestComponent
  • How to use Mockito to Create a mock object
  • How to set return values on a mock object
  • How to override a Dagger component in androidTest
  • How to create a custom module that returns a mocked object through Dagger
  • How to create a Test Application that is invoked instead of the default Android application (during test only!)
  • How to create a MockTestRunner that will load your Test Application
  • How to tell Android how to use your custom Test runner that you built
  • How to build a stub that your mock object can return
  • How to inject a mock into your test so that you can set stub values and expectations on it
  • How to use Espresso to verify that the screen did output the value from the mock

- Dagger 2
- Mockito




There are no comments on this lesson, start the conversation below ...


Lessons in Dagger 2 (retired)