commit | 9209e74b6fc3f4547360746c9439c224631dfd0c | [log] [tgz] |
---|---|---|
author | Treehugger Robot <[email protected]> | Wed May 31 08:39:32 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed May 31 08:39:32 2023 +0000 |
tree | f66c05fc4ee0c136e252ed7c5d75fb0f70b02f1c | |
parent | 5fdd3d77cea239aeda622d34f92ab54afc9361c6 [diff] | |
parent | 1c4ac2be71c61e5d949c86bac60c60933b6d124f [diff] |
[automerger skipped] Merge "mobly-snippet-lib: Allow snippet install on R devices" am: 04e64ee635 am: 598172d15b am: 37474234a6 -s ours am: 2915544dbb -s ours am: 1c4ac2be71 -s ours am skip reason: Merged-In Ia7df616d0aff82e68fd185b9691959a7832c844b with SHA-1 a7badbfa0c is already in history Original change: https://android-review.googlesource.com/c/platform/external/mobly-snippet-lib/+/2609551 Change-Id: I3bfd3b961eb3d37d8c14088310856926b19898c1 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.