Join Chiu-Ki Chan for an in-depth discussion in this video Separation of concerns, part of Effective Android Testing for Mobile Developers.
- [Instructor] Espresso allows us to exercise and verify the UI of our app, but tests often break when we update a UI. The robot pattern mitigates that by separating the what from the how. In the recipe example, our robot has a function called Is Favorite. This extracts the how, verifying that the recipe is a favorite away from the what that the title Is Selected. When we update a UI, we have a central place that updates the how while keeping the what intact.
In other words, the test will still call Is Favorite on the robot whenever it wants to verify that the UI shows the recipe as a favorite. If you take a look at the test itself, you can see that we call Is Favorite in already favorite. And if you re-factor cut to favorite, the same is going to apply to the Cut To Favorite function. When we change the UI, we only need to update the Is Favorite function.
In one central place, we will be able to change the logic of our test to reflect the UI changes. The separation of concern of what versus how makes our test more robust to changes. In the next chapter, we will look into another testing technique, the Model View Present a Pattern, also known as MVP. MVP allows us to separate pure Java logic from Android classes and therefore run lightning-fast tests on the JVM without a device.
- 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 Studio Essential Trainingwith David Gassner3h 41m Beginner
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m 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.