commit | ae5b1ec8a57d9cd6259556f14d3f2bb4f9fb3a85 | [log] [tgz] |
---|---|---|
author | Ziwei Zhang <[email protected]> | Thu Apr 11 11:36:08 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Apr 11 11:36:08 2024 +0000 |
tree | 38533c9648bef596a95c5fa85774a4946e992625 | |
parent | a3af46165c6d4168bb33d6e97b9959eba531b5bd [diff] | |
parent | 42ad1a03c67c59459c7d03930e4c2278860f0b3e [diff] |
Upgrade mobly-snippet-lib to 3c705915cad43acd88a8815b3f3e3cf9455a60a4 am: 23cff8ec53 am: 42ad1a03c6 Original change: https://android-review.googlesource.com/c/platform/external/mobly-snippet-lib/+/3033152 Change-Id: I15be669e529e7dc21bc6f4eaf4d86e40ba988ec0 Signed-off-by: Automerger Merge Worker <[email protected]>
Mobly Snippet Lib is a library for triggering device-side code from host-side Mobly tests. This tutorial teaches you how to use the snippet lib to trigger custom device-side actions.
Note: Mobly and the snippet lib are not official Google products.
The Mobly Snippet Lib allows you to write Java methods that run on Android devices, and trigger the methods from inside a Mobly test case. The Java methods invoked this way are called snippets
.
The snippet
code can either be written in its own standalone apk, or as a product flavor of an existing apk. This allows you to write snippets that instrument or automate another app.
A snippet is launched by an am instrument
call. Snippets use a custom InstrumentationTestRunner
derived from AndroidJUnitRunner
. This allows for snippets that interact with a main app‘s classes, such as Espresso snippets, and allows you to get either the test app’s or the main app's context from InstrumentationRegistry
.
Once started, the special runner starts a web server which listens for requests to trigger snippets. The server's handler locates the corresponding methods by reflection, runs them, and returns results over the TCP socket. All common built-in variable types are supported as arguments.
The examples/ folder contains examples of how to use the mobly snippet lib along with detailed tutorials.