Discover how to exercise services with ServiceTestRule, and how to create and use custom service test rules.
- [Voiceover] The Android Testing Support Library…supports testing background services with another rule.…Namely, a ServiceTestRule.…Like ActivityTestRule,…there's a built in ServiceTestRule…that you can use with the rule annotation…in your instrumented test to create an instance of a service…for your test method.…You can also extend and customize a ServiceTestRule…if you want to set up and clean up…the Android environment and the service itself…before and after you had tested the service.…
Before we can begin to understand…ServiceTestRules, I need to add a simple…Android service that we can use to explore the rules.…One critical note before creating MyService,…ServiceTestRule supports testing regular…Android services, but not IntentServices.…If you are unfamiliar with the difference…between a regular service and an IntentService,…check out this resource, it provides…a nice little synopsis.…I started Android Studio and opened…project 03_04_start in order to…explore ServiceTestRule.…
I create a new service by selecting…
Author
Released
7/19/2016- 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
Duration
Views
Related Courses
-
UX Foundations: Usability Testing
with Chris Nodder1h 29m Beginner
-
Introduction
-
Welcome49s
-
What you need to know1m 44s
-
-
1. Getting Started
-
Why unit test?6m 37s
-
How much unit testing6m 57s
-
Unit testing tools6m 21s
-
Local and instrumented tests6m 16s
-
-
2. Local Tests
-
JUnit basics6m 8s
-
Beyond JUnit basics7m 57s
-
Assertions2m 39s
-
Hamcrest5m 43s
-
Rules6m 3s
-
Categories5m 34s
-
-
3. Instrumented Tests
-
Android instrumented tests6m 47s
-
Executing instrumented tests3m 56s
-
Android test rules9m 46s
-
Service test rules6m 40s
-
Test filtering8m 6s
-
-
4. Other Android SDK Testing Tools
-
UI testing and UI Automator7m 54s
-
UI Automator API6m 54s
-
MonkeyRunner6m 29s
-
-
5. Mocking objects
-
Mock objects5m 38s
-
Mockito8m 40s
-
Android mocks4m 49s
-
-
Conclusion
-
Next steps18s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Service test rules