| commit | d1c5e3d7cc5cc020e24469191f617213701f96c9 | [log] [tgz] |
|---|---|---|
| author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Dec 20 18:09:52 2024 -0800 |
| committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Dec 20 18:09:52 2024 -0800 |
| tree | a53944d777eabea6159d419ebd1d1cad6c19a020 | |
| parent | ae5b1ec8a57d9cd6259556f14d3f2bb4f9fb3a85 [diff] | |
| parent | 68507994db178b5747c60819f42ec1d6e4b1f7bb [diff] |
Snap for 12838584 from 68507994db178b5747c60819f42ec1d6e4b1f7bb to 25Q2-release Change-Id: I552966f8ad16f591d40478baa2785f1b8ddc3242
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.