Join Chiu-Ki Chan for an in-depth discussion in this video Mockito: Intro, part of Effective Android Testing for Mobile Developers.
- [Instructor] Wait, we did all that just to have to add work exactly the same? What's the point? Remember, we are trying to isolate the presenter from Android classes so that we can test it on the JVM which is much faster. So, let's test the presenter. Put your cursor on the class name, press CMD + SHIFT + T to create a new test. Press Okay, and then instead of putting it in the Android test folder, we're going to put it in the test folder because we want to run it on the JVM.
Press OK. Go back to the presenter. To test the presenter we will need to create one. That requires a recipe store, the view contract, and also favorites. Instead of passing its actual implementations, we are going to stub them. What is a stub? A stub is a kind of test double just like the one we used in the Espresso module. There, we used an in memory favorite in place of shared preferences favorite.
Here, we are going to use the Mockito library to stub the dependency for our presenter. So let's do that next.
- 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 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.