Learn about Android SDK's mock types, including the benefits of use, how to use them, and when to use them.
- [Voiceover] The Android STK provides several mock objects…in the android.test.mock package.…Some of these would be classified as stub or dummy types…under stricter testing terms discussed in this chapter.…The API includes mock objects for…the types you see listed in this table.…These Android types are often needed to be passed…as parameters in a number of Android APIs,…or used to get Android resources,…such as databases, preferences, etc.…The advantage of using these mock objects…is that they come with the Android STK.…
As these are provided by the STK,…simply use the API in your tests.…The mock objects are made part of the test package…along with test classes, instrumentation…code and JUnit code when required.…Calling a method on most of these mock objects…causes an unsupported operation exception to be thrown.…The mock objects are non-functional empty shells.…You need to provide your implementation…for methods your code exercises during testing.…Remember, a mock object is a stand in,…or place holder object for the real object.…
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
Foundations of UX: Usability Testingwith Chris Nodder1h 29m Beginner
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.