失效链接处理 |
Android Espresso Revealed PDF 下载
本站整理下载:
提取码:nhie
相关截图:
主要内容:
Chapter Overview
Chapter 1: Getting Started with Espresso for Android
This chapter describes the basics of Espresso. It defines goals and approaches of user
interface testing and provides examples for setting up tests inside the Android Studio
IDE project. It also explains how to identify Android application UI elements, perform
actions and assertions, and apply matchers to them. At the end of this chapter, you will
be able to write simple tests and execute them from inside the Android Studio IDE on the
device or emulator. It also includes examples for how to run tests using Gradle or shell
commands.
Chapter 2: Customizing Espresso for Our Needs
With more advanced examples, you will learn how to implement a custom ViewAction,
including clicks and swiping actions; and a ViewMatcher, such as matching complex
views as RecyclerView matchers. You will learn how to use custom actions and
matchers, implement a custom FailureHandler with the possibility to take and save
screenshots upon failure.
Chapter 3: Writing Espresso Tests with Kotlin
This chapter gives an overview of the benefits of using the Kotlin programming language
in tests and explains how to migrate tests written in Java to Kotlin. It also provides an
example of creating an Espresso domain specific language in Kotlin.
Introduction
xv
Chapter 4: Handling Network Operations and
Asynchronous Actions
This chapter explains how to handle application network requests and long-lasting
operations during test execution with the help of the IdlingResource interface. It
provides an example of using ConditionalWatcher as an alternative to IdlingResource.
Chapter 5: Verifying and Stubbing Intents with
IntentMatchers
This chapter explains using IntentMatchers inside an application as well as how to stub
external intents and provide extras. A good example of an external intent is selecting an
image from the photo gallery, which then can be used by the application you’re testing.
Chapter 6: Testing Web Views
This chapter covers testing WebViews inside an application. Implemented WebViews
showcase different UI elements that the Espresso-Web API is able to operate on. You will
be provided an Espresso-Web cheat sheet as part of the book’s content.
Chapter 7: Accessibility Testing
This chapter unleashes the topic of how to test application accessibility using Espresso
for Android. It raises awareness about the importance of accessibility testing and
provides an overview of manual tools that can be used to test application accessibility.
Chapter 8: Espresso and UI Automator:
The Perfect Tandem
This chapter explains one of the most powerful test automation setups for Android,
which combines the Espresso test framework with the UI Automator testing tool.
Examples show how to test notifications or operate on third-party apps during Espresso
tests execution.
Introduction
xvi
Chapter 9: Dealing with Runtime System Actions and
Permissions
This chapter explains different ways that you can deal with system actions like
permission request dialogs and describes possible solutions for changing the Android
emulator system language programmatically.
Chapter 10: Android Test Automation Tooling
After reading this chapter, you will understand how to use the Espresso test recorder,
set up a test device or emulator to minimize test flakiness, and run tests in the Firebase
cloud.
Chapter 11: Screen Object Design Pattern in
Android UI Tests
This chapter shows you how to apply the screen object (the same as page object)
architecture approach to the test project, which allows you to reduce the maintenance
effort spent on reworking tests after changes in the application’s source code.
Chapter 12: Testing the Robot Pattern with Espresso
and Kotlin
In this chapter, you learn how to apply a testing robot pattern that splits the test
implementation from the business logic to the Espresso UI tests.
Chapter 13: Supervised Monkey Tests with Espresso
and UI Automator
This chapter shows how to implement supervised pseudo-monkey tests using Espresso
and UI Automator, which can be applicable to applications whose source code you have
access to as well as to third-party applications.
Introduction
xvii
Chapter 14: AndroidX Test Library
This chapter demonstrates how to migrate test code from Android support to the
AndroidX Test library. You will find information about new APIs introduced in the
AndroidX Test library and see how they can be applied to UI tests.
Chapter 15: Improving Productivity and Testing Unusual
Components
This chapter contains code samples that were not covered in the other chapters and
Espresso testing tips that may increase your daily test writing productivity. This includes
creating parameterized tests, aggregating tests into test suites, using AndroidStudio
Live templates in UI tests, setting SeekBar progress in Espresso UI tests, and Espresso
Drawable matchers topics.
What This Book Doesn’t Cover
The goal of the book is to create a guide for how to write end-to-end UI automated tests
for Android applications without mocking or stubbing application dependencies. From
my point of view, this is the closest way to reproduce end user behavior. The book does
not explain how to mock application data and network connection requests or bypass
some states in the application workflow.
Tools Requirements
To be able to work with this book, you need to have at least a basic knowledge in working
with such tools and platforms as Android Studio IDE, Gradle, GitHub, and shell/bash. In
most cases, I explain how to configure your IDE and note which commands should be
used to run the specific scripts.
Legal Notice
This book contains code, documentation, and images taken from the Android
developers page at https://developer.android.com. They are covered by the Apache
2.0 License (http://www.apache.org/licenses/) mentioned in Appendix C.
Introduction
CHAPTER 1
Getting Started with
Espresso for Android
Espresso for Android is a lightweight, fast, and customizable Android testing framework,
designed to provide concise and reliable automated UI tests. At the end of October
2013, Espresso was open sourced by Google after it was announced at the Google Test
Automation Conference. From that moment it has been gaining popularity across
Android software and test engineers. Now it is the most popular testing framework for
the Android platform because its features and development are driven by Google and
the Android Open Source community.
This chapter describes Espresso’s basics—the core components of the Espresso
testing framework that are used in test automation to replicate the end user behavior.
This includes locating application UI elements on the screen and operating on them.
Espresso includes the following packages:
• espresso-core—Contains core and basic view matchers, actions,
and assertions.
• espresso-contrib—External contributions that contain DatePicker,
RecyclerView, and Drawer actions, accessibility checks, and the
CountingIdlingResource. • espresso-intents—Extensions to validate and stub intents for
hermetic testing.
• espresso-idling-resource—Espresso’s mechanism for
synchronizing background jobs.
• espresso-remote—Location of Espresso’s multi-process functionality.
• espresso-web—Contains resources for WebView support.
|