- [Instructor] Now that we have "SharedPreferencesFavorites"…and "InMemoryFavorites",…how do we use one in the app,…and the other in the test?…We will use "Application" to help us.…First, let's create the application.…Go to "app", "src", "main", "java",…right click on the package name, "New", "Java Class".…We will call it "RecipeApplication".…The package will have the prefix, ".injection".…
The "RecipeApplication" will extend "Application".…Inside this "Application",…we are going to add a function called "getFavorites".…This will return a latently-initialized…"SharedPreferencesFavorites".…This way, it is only going to be initialized…when someone uses it.…To do that, we will add a private variable,…"private Favorites" and put "favorites",…and set it to "null;" initially.…
Then we will add the "getFavorites" function,…"public_Favorites getFavorites()".…When the variable favorites is null,…we will need to initialize it,…"if (favorites == null)",…then "favorites = new SharedPreferencesFavorites".…It need a context, which is "(this)", the application.…
- Why test?
- Local vs. on-device
- Code coverage
- UI testing
- Hermetic environment
- Dependency injection
- Testing with MVP
Skill Level Intermediate
1. Testing Considerations
2. Test as You Go
3. UI Testing
4. Hermetic Environment
5. Robot Pattern
- 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.