Join Chiu-Ki Chan for an in-depth discussion in this video UI-less on-device test: Count test, part of Effective Android Testing for Mobile Developers.
- [Instructor] We have verified that our recipe store handles a nullDirectory properly. Let's actually read the recipes out of our assets directory of the app. Go ahead and click on assets, and you can see that under the recipes directory, there are four recipes. We will verify that they can be read from the recipe store correctly. Copy and paste the nullDirectory test method from line 11 to 18.
Change the name to count, because we are going to verify the count of the number of recipes in the assets folder. In line 23, instead of passing null after directory name, we will pass recipes, which corresponds to the folder name under assets. Look at the next line. It says assertnotnull, which is still true. We still want to make sure that this recipe store in notnull.
The next line we are asserting that the recipes within the store is notnull, which again is the same. But the final line asserts equal should not be zero, because we're expecting that we are going to have four recipes. Just for the sake of argument, let's run the test and see it fail. Click on the green triangle and wait. Indeed, it fails. If you double-click on the word count, you can see that it says it expected zero, but it was four.
So let's make this test pass by giving it the correct number of recipes. Run the test again. And it passes.
- 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.