Join Chiu-Ki Chan for an in-depth discussion in this video Dagger component, part of Advanced Android Espresso Testing.
- [Instructor] To create a Dagger component,…move your cursor to the package name under main.…Right click, select new, Kotlin File.…Call it ApplicationComponent.…We will create an interface.…We want this component to have a module for our clock.…So let's create the clock module.…
@Module, this is from Dagger,…then object ClockModule.…Inside we will provide a clock.…We use the annotation @ provides to tell Dagger…that this function can be used to provide a clock.…Fun provideClock…and then we will tell Dagger that it returns a clock.…
Inside the function body,…return Clock.…Now that we have defined our module,…let's use it in the component.…Go to line six, add @Component…modules = an array…containing ClockModule::class.…We need this component to be able…to inject a clock into our activity.…
On line nine, we will add a function inject.…Fun inject…(mainActivity: MainActivity).…This means that we want Dagger…to generate an inject function…which can inject our clock into MainActivity.…Now that we have an application component,…
- Incoming and outgoing intents
- How intents are used
- Dependency injection
- Why extract dependencies?
- Mockito and Dagger
Skill Level Advanced
Effective Android Testing for Mobile Developerswith Chiu-Ki Chan2h 56m Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
2. Hermetic Test Environment
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.