Package Overview
How the testrelic-appium pytest plugin works: auto-wrap, the assert_that API, CLI subcommands, and installation.
testrelic-appium is distributed on PyPI and installs as a pytest plugin. This page explains how the pieces fit together.
Install
pip install testrelic-appiumTo enable the mitmproxy network fallback, install the network-proxy extra:
pip install "testrelic-appium[network-proxy]"pytest plugin and auto-wrap
The plugin registers through a pytest11 entry point, so it activates as soon as it is installed — no conftest.py changes required. For each test, it walks item.funcargs and wraps any appium.webdriver.webdriver.WebDriver instance it finds. Pure-Selenium tests carry no Appium driver, so they are never touched.
When you want explicit control over which driver is instrumented, two manual entry points are available:
testrelic_appium_driverfixture — request it in your test signature to receive a function; call it with your driver to instrument it and get the driver back.wrap_driver()function — wrap a driver you constructed yourself.
def test_login(testrelic_appium_driver, my_driver):
driver = testrelic_appium_driver(my_driver)
driver.find_element("accessibility id", "username").send_keys("alice")You can also disable auto-wrap entirely with the --testrelic-no-autowrap CLI flag.
Assertion API
Import assert_that to record a named assertion as a discrete event on the timeline:
from testrelic_appium import assert_that
with assert_that("toHaveText", expected="Welcome"):
assert el.text == "Welcome"Passing bare assert statements are also recorded — but only when they are not inside an assert_that block, so assertions are never double-counted. This uses pytest's assertion-pass hook, which you turn on in your pytest config:
[tool.pytest.ini_options]
enable_assertion_pass_hook = trueCLI subcommands
The package installs a testrelic-appium command for working with reports and the offline queue:
| Command | Description |
|---|---|
testrelic-appium version | Print the installed version. |
testrelic-appium merge shard-1.json shard-2.json -o merged.json | Merge timeline shards (e.g. from parallel runs) into one file (-o defaults to merged.json). |
testrelic-appium serve ./test-results [--host 127.0.0.1] [--port 9323] [--open] | Serve a report directory locally (port defaults to 9323, falling back to a free port if taken). |
testrelic-appium drain [--queue-dir PATH] | Flush the offline upload queue to the cloud. |
testrelic-appium cleanup-queue [--queue-dir PATH] [--max-age-days 7] | Remove stale entries from the offline queue. |
The offline queue lives in .testrelic/queue/ by default.