Join Chiu-Ki Chan for an in-depth discussion in this video Outgoing intents: Launch activity, part of Advanced Android Espresso Testing.
- [Narrator] Now that we have tested how ideas activity…receives an intent, let's test…how main activities sends one.…Press Command+All to open main activity.…Scroll up, and put your cursor…on the class name, main activity.…Press Command+Shift+T to create a test.…Add a body to the test class and annotate the whole class…with run with and then AndroidJUnit, colon, colon, class.…
Then, as usual, we will also need to add a test rule.…Add rule, add JvaField, and then var activityRule.…Then activity test rule with the parameter MainActivity,…colon, colon, class.java.…Quick reminder.…The class annotation runs with means…that we are running all these tests as Android tests…and activity rule means that we want…to launch the activity before every test method.…
Now we can add our test method.…Press Command+N to choose test function.…We will call it punny.…Delete the to do.…We are calling this method punny…because we are going to click on the button that says punny.…On view, withId, R dot id dot button underscore punny.…
Press Alt+Enter for the imports.…
- Incoming and outgoing intents
- How intents are used
- Dependency injection
- Why extract dependencies?
- Mockito and Dagger
Skill Level Advanced
Effective Android Testing for Mobile Developerswith Chiu-Ki Chan2h 56m Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
2. Hermetic Test Environment
- 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.