Join Chiu-Ki Chan for an in-depth discussion in this video Refactor: Load recipe, part of Effective Android Testing for Mobile Developers.
- [Instructor] We have identified…the five things that RecipeActivity do.…Let's refactor them into the presenter one by one.…Step one only sets up the UI.…There is no logic…so it stays in the activity.…Step two extracts the recipe ID from the intent in line 30.…This part stays in the activity…because there's no other way to get hold of the intent.…In line 31 we use this ID to load the recipe.…
This can go inside the presenter…as long as the presenter is initialized with a RecipeStore.…So, let's do that.…In the UI Recipe folder that we created the contract,…right click, New, Java Class.…We will call it RecipePresenter.…Add a private final field RecipeStore,…private final RecipeStore…and we'll name it store.…Alt enter to add a constructor parameter.…
Now that we have a store,…we can use it to load the recipe…when someone give us an ID.…Add a new function.…Public void loadRecipe.…Pass it the ID as a string.…Recipe equal store.getRecipe ID.…Great, now we have a recipe.…What do we do with it?…We have two choices,…either return it back to the activity…
- Why test?
- Local vs. on-device
- Code coverage
- UI testing
- Hermetic environment
- Dependency injection
- Testing with MVP
Skill Level 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.