Use ActivityTestRule with @Rule and create custom ActivityTestRules. In this movie, you'll also learn how to access and use instrumentation information.
- [Voiceover] Up to now, I've shown…some simple, general tests in the test class…that is simple math test, of my instrumented test example.…These tests don't exercise anything of the Android API…and don't really need to run as instrumented test.…They could easily be constructed as local tests.…When you want to start exercising the Android API,…namely activities and services,…you use the Android testing support library's J-Unit rules.…If you skipped Chapter 2-7,…you may want to return to learn about JUnit rules.…
Rules define the code that executes before…and/or after unit tests.…In the case of Android instrumented tests,…these rules are used to trigger the creation…of Android elements like an activity…or a service that you want to exercise and test…in the unit test methods.…I started Android studio and opened project 03_03_start.…To use the Android testing support library's rules,…I first need to add another Android test compiled…dependency to my Build_gradle file.…
Namely, I need to add the com.android support test…
AuthorJames P White
- Why unit test?
- Unit testing tools
- Local testing with JUnit
- Working with JUnit assertions, rules, and categories
- Executing instrumented tests
- Filtering tests
- Testing with UI Automator and other testing tools
Skill Level Intermediate
1. Getting Started
2. Local Tests
3. Instrumented Tests
4. Other Android SDK Testing Tools
5. Mocking objects
- 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.