From the course: Advanced Android Espresso Testing
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
TestApplication - Android Tutorial
From the course: Advanced Android Espresso Testing
TestApplication
- [Instructor] Now that we have extracted the time dependency into the application, we will create a test application so that we can override provideClock to return a fixed time. Go to your project tree and expand Android test. Click on the package name, right click, New, Kotlin File/Class. We will call it TestApplication. Inside, we will create the class TestApplication. Class TestApplication: GreetingApplication. This means that we want to subclass GreetingApplication. However, Kotlin is not happy because GreetingApplication, by default, is a final class. Press Alt + Enter to make it open. If you Command + click on GreetingApplication, you can see on line five that the keyword open has been added for us. With that, we can subclass GreetingApplication. On the gutter, you can see that there's an O, arrow down. That means there's a subclass, and when you click on it, it will jump to the TestApplication subclass. We have this subclass because we want to override the provideClock method,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
App: Greetings2m 10s
-
Dependency injection52s
-
GreetingApplication3m 33s
-
Why extract dependencies?55s
-
TestApplication3m 36s
-
CustomTestRunner2m 25s
-
Mockito6m 12s
-
Dagger2m 17s
-
Dagger dependencies2m 16s
-
Dagger component2m 13s
-
Use Dagger in application3m 23s
-
Dagger TestComponent3m 11s
-
MainActivityTest4m 47s
-
-
-