Join Chiu-Ki Chan for an in-depth discussion in this video InMemoryFavorites, part of Effective Android Testing for Mobile Developers.
- [Instructor] In recipe activity,…we use two functions…from shared preferences favorites,…get and toggle.…Let's create an interface for that,…so that we can provide an in-memory version…during test.…Right-click on data local, new, Java class.…Call it favorites and change the kind from class…to interface.…Press okay.…We will need to add the signature for get…and toggle, so let's copy that…from shared preferences favorites.…
Copy the function signature in line 13…from Boolean to the parenthesis.…Paste it in favorites and add a semicolon.…Go back and do the same for toggle.…Next, we will go back to shared preferences favorites…and have it implement this interface.…Implement favorites.…Now that we have an interface…we are going to create the in-memory version.…
Go to the Android test package,…right click on the package name, new, Java class.…We will call it in memory favorites.…The package name is going to be .data.local.…Press okay.…We will need to have in-memory favorites…implement favorites, the interface.…Then, press Alt + Enter to implement methods.…
- Why test?
- Local vs. on-device
- Code coverage
- UI testing
- Hermetic environment
- Dependency injection
- Testing with MVP
Skill Level Intermediate
Android App Development: Unit Testingwith James P White2h 58m Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m 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.