- [Instructor] For our first test method, let's test a case…when the recipe is not found.…Create a new test method…by starting with the annotation Test.…Then public void recipeNotFound.…To test the case when recipe is not found,…what we are going to do is we are going to call…the load recipe function and then specify that…whenever somebody tries to load anything out of the store,…we return a null object.…
To specify that behavior of the store,…we are going to use Mockito.…Here is how you do it.…Mockito.when…store.getRecipe…and then Mockito.anystring go to the end of the line,….thenreturn, null.…Wow, that is not obvious at all,…So let's walk through it.…When we say Mockito when, and then return,…it means that we are specifying the behavior…when a function is called.…
Here, we are saying that when the get recipe function…is called on the recipe store,…whatever the perimeter is,…that's what we mean by Mockito dot any string,…we are going to return null.…We are doing that so that…when call presenter dot load recipe,…it can go to the store, and then return a null.…
- 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.