Join Chiu-Ki Chan for an in-depth discussion in this video CustomTestRunner, part of Effective Android Testing for Mobile Developers.
- [Instructor] To use test recipe application during test we will need a custom test runner. Let's create that now. Right click on the package name under Android Test select New, Java Class We will call it CustomTestRunner Append dot test to the package name. CustomTestRunner will extend Android J unit runner. Extends AndroidJUnitRunner.
To have the custom test runner extenuate test recipe application instead of the normal recipe application, we will need to override the new application function. Press control alt, and type NewApplication. Press OK Inside the body of NewApplication, in line 10, we are going to keep the super core to NewApplication. However we are going to replace the second perimeter from className to test recipe application.
So go ahead and replace that with TestRecipeApplication dot class dot get name To use the custom test runner we need to update App slash build the gradle Copy and paste the package name from here and then go to gradle file. In line 13 replace the TestInstrumentationRunner value with our custom test runner. We need the full name, which is why we copied the package name.
Paste it in and append dot CustomTestRunner Press Synch Now. Now we can run the test. Press command o to go to recipe activity test. Click on the green triangle on the gutter and choose Run. Use the same selection. Yay, this time it passes because it is using the in-memory favorites. Let's run it again just for good measure.
And it still passes. Next, we are going to add a test method which tests a case when we have a recipe that has been previously favorited.
- 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.