- [Instructor] Now we are ready to write the test.…Put your cursor on the class name MainActivity…and press Command + Shift + T to create a new test.…We'll call it MainActivityTest,…and then we will check the checkbox…for greet to generate a test method for it.…Press okay, and your studio automatically generated…the skeleton for our Espresso test.…
It is under the folder androidTest…and then under the same package name as MainActivity.…The first thing we want to do…is to add the annotation to the class itself,…RunWith…and then…AndroidJUnit4::class.…Press Alt + Enter to import.…
This annotation means that all the tests in this class…are Android tests.…Next we need to add an activity test rule.…The activity test rule is used…to tell Espresso which activity to launch…before running each test method.…@Rule,…@JvmField,…and then var activityRule…equal ActivityTestRule,…and then we will give the type MainActivity,…and the parameter to instantiate this rule…is MainActivity::class.java.…
Press Alt + Enter to import ActivityTestRule.…
- Advantages of Espresso and automated testing
- Adding Espresso to an Android project
- Creating your first test
- Recording actions in the Test Recorder
- Pinpointing a view
- Testing list views
- Testing recycler views
Skill Level Beginner
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
Effective Android Testing for Mobile Developerswith Chiu-Ki Chan2h 56m Intermediate
Advanced Android Espresso Testingwith Chiu-Ki Chan1h 37m Advanced
1. What Is Espresso?
2. Your First Espresso Test
3. Espresso Test Recorder
4. Pinpointing a View
5. List View
6. Recycler View
- 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.