Join Chiu-Ki Chan for an in-depth discussion in this video Smallest unit first, part of Effective Android Testing for Mobile Developers.
- [Instructor] Effective testing should allow us to pinpoint to the exact place where we have a problem. The best way to do that is to make each test as specific as possible. To do that, we will build our app from the smallest unit first. In this app it is the recipe. Let's create a new class called recipe. We will put it under the data model package. Right click on this long package name under Java, click new, Java class.
We will call it recipe and change the package to data.model. Click okay. Each recipe has three public final string fields, ID, title, and description. To create another public final string field we will use the duplicate command, Command + D, and change the variable name description. And our studio is not happy because these final fields are not initialized.
We will generate a constructor to do that. Press Alt + Enter, add construction parameters, select all three parameters, change the constructor to be private because we are going to make a static factory method to parse the recipe and create it. The static method is going to be called read from stream. Public, recipe, read from stream.
It will take an input stream as the parameter. For now, let's have it return null. The idea here is that we are going to read from an input stream, parse all the text, assign them into the fields ID, title, and description, and then create a recipe with the private constructor. The reason why we are using an input stream is because, to read things out of the asset folder we will use an input string.
Next, we are going to implement this function using TDD, test driven development.
- 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.