Sign in Go Pro

Dependency Injection with Dagger 2

Espresso tests and Dagger: Adding the TestApplicationComponent

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

In this lesson we create an internal testing module along with the TestApplicationComponent. This is a test Component that will extend our ApplicationComponent. We can use this to provide different implementations of dependencies in UI tests.

Comments

Hi,

At about 1:40 you are talking about doubling down on some code debt. I understand the term code debt. But can you explain the part about we should have moved appcomponent. Is there something we should have done different or if there is a potential issue? And following on in this tutorial is this the best way to do this? Thanks

Hi Steve,

I was referring to the appcompat dependency, where we have the version explicitly inline, rather than having the version be defined in the project level build.gradle file, where we have other common dependencies/versions defined. In short, there should be a value for appcompat here: https://github.com/bgogetap/GitHubBrowser-Dagger-Sample/blob/29-espresso-test-application-component/build.gradle#L41

Rewatching the part you reference, I can get the confusion as I was actually referring to a dependency a few lines down from where the cursor was--sorry about that.

Ideally, there should be no explicit com.dep:dep-artifact:dep.version in module build.gradle files. Instead, having Deps.artifact, which is defined in the project level build.gradle file, makes for easier maintenance of the project and dependency versions as time goes on.

>

Lessons in Dependency Injection with Dagger 2

1. Intro to Dependency Injection - Simple example with no DI
01:47
Brandon Gogetap
2. Intro to Dependency Injection - Dependency Injection in Practice
00:35
Brandon Gogetap
3. Why we use Dependency Injection
01:59
Brandon Gogetap
4. How Dependency Injection frameworks help
00:37
Brandon Gogetap
5. What we're building - Final Product
01:04
Brandon Gogetap
6. Creating the GitHub Browser Project
01:45
Brandon Gogetap
7. Creating the Application Component Interface
01:10
Brandon Gogetap
8. Building the Application Component
01:02
Brandon Gogetap
9. Dagger codegen: Inspecting the generated Application Component
00:47
Brandon Gogetap
10. Adding the GitHubApi Module
02:01
Brandon Gogetap
11. Creating a Dagger 2 Module
02:36
Brandon Gogetap
12. Creating the AppRepository - The single source of data for the UI
Pro
02:47
Brandon Gogetap
13. Dagger codegen: Checking in on the generated Application Component
Pro
02:41
Brandon Gogetap
14. Unit Testing the AppRepository
Pro
03:07
Brandon Gogetap
15. Feature: Home Screen
Pro
01:55
Brandon Gogetap
16. Home Screen Repository List Setup
Pro
04:40
Brandon Gogetap
17. Home Screen ViewModel
Pro
04:34
Brandon Gogetap
18. Injecting a Jetpack ViewModel
Pro
03:14
Brandon Gogetap
19. Exposing Singleton Dependencies in a Modular Way
Pro
02:34
Brandon Gogetap
20. Home Screen Component
Pro
04:01
Brandon Gogetap
21. Dagger codegen: Component Dependencies
Pro
03:16
Brandon Gogetap
22. Dagger codegen: Multibindings
Pro
02:31
Brandon Gogetap
23. Dagger codegen: @Binds, @Provides, and Modules
Pro
03:03
Brandon Gogetap
24. Matching Dagger Component Scopes with ViewModel Scopes
Pro
04:07
Brandon Gogetap
25. Unit Testing HomeViewModel
Pro
04:14
Brandon Gogetap
26. Displaying fake data in the Home Fragment
Pro
03:39
Brandon Gogetap
27. Espresso tests and Dagger: Modularizing ApplicationComponent
Pro
02:39
Brandon Gogetap
28. Espresso tests and Dagger: Adding the TestApplicationComponent
Pro
04:42
Brandon Gogetap
29. Espresso tests and Dagger: Adding the Test Application and Runner
Pro
01:49
Brandon Gogetap
30. HomeFragment Espresso Test
Pro
03:56
Brandon Gogetap
31. Retrofit integration: Suspend Functions
Pro
03:49
Brandon Gogetap
32. Retrofit integration: Preparing for the real GitHub API
Pro
04:00
Brandon Gogetap
33. Retrofit integration: Swapping mock GitHubApi with implementation created by Retrofit
Pro
04:11
Brandon Gogetap
34. Dagger Modules: Build variants/flavors
Pro
01:46
Brandon Gogetap
35. Dagger codgen: Effects of Module changes
Pro
02:19
Brandon Gogetap
36. Feature: Repo Details Screen
Pro
01:20
Brandon Gogetap
37. Repo Details Component
Pro
01:55
Brandon Gogetap
38. RepoDetails ViewModel Part 1
Pro
01:40
Brandon Gogetap
39. Dagger codegen: Qualifier Annotations
Pro
01:30
Brandon Gogetap
40. Extending GitHub API: Single repository fetch
Pro
01:31
Brandon Gogetap
41. AppRepository updates: Caching and new request
Pro
01:19
Brandon Gogetap
42. AppRepository Unit Test Updates
Pro
02:05
Brandon Gogetap
43. Repo Details Contributors List Setup
Pro
01:29
Brandon Gogetap
44. Repo Details View States
Pro
02:12
Brandon Gogetap
45. Repo Details ViewModel Test
Pro
01:35
Brandon Gogetap
46. Hooking up RepoDetailsFragment with View States
Pro
01:43
Brandon Gogetap
47. RepoDetailsFragment Espresso Test
Pro
02:34
Brandon Gogetap
48. Preparing for screen navigation
Pro
04:08
Brandon Gogetap
49. Activity Scoped Component
Pro
01:43
Brandon Gogetap
50. Activity Screen Navigator
Pro
02:04
Brandon Gogetap
51. Fake ScreenNavigator: A fake navigator for tests
Pro
01:12
Brandon Gogetap
52. Navigating from the Home screen to the Details screen
Pro
03:36
Brandon Gogetap
53. Dagger codegen: Walking through all the layers
Pro
06:03
Brandon Gogetap
54. PowerAdapter - A Dependency Injection driven RecyclerView Adapter
Pro
01:32
Brandon Gogetap
55. Using PowerAdapter for the Home screen
Pro
03:37
Brandon Gogetap