Configuration
Every testrelic-appium option: testrelic_options keys, CLI flags, environment variables, capture toggles, and redaction.
testrelic-appium is configured through pyproject.toml, command-line flags, and environment variables. Most teams set defaults in pyproject.toml and override per-run from the CLI.
testrelic_options in pyproject.toml
Set options under [tool.pytest.ini_options] using the testrelic_options list:
[tool.pytest.ini_options]
testrelic_options = [
"outputPath=./test-results/testrelic-timeline.json",
"screenshotOnEvery=on-failure",
"includeNetworkLogs=true",
]Option reference
| Key | Type | Default | Description |
|---|---|---|---|
outputPath | str | ./test-results/testrelic-timeline.json | Where the JSON timeline is written. |
htmlReportPath | str | derived | Where the HTML report is written (derived from outputPath when unset). |
openReport | bool | false | Open the HTML report automatically after the run. |
includeDeviceLogs | bool | true | Capture Android logcat / iOS syslog + crashlog. |
includeNetworkLogs | bool | true | Capture HTTP requests/responses. |
includeConsoleLogs | bool | true | Capture webview/browser console output. |
includeScreenshots | bool | true | Capture screenshots. |
screenshotOnEvery | off | on | on-failure | on-every-step | on-failure | Screenshot policy. |
includeVideoRecording | bool | false | Record device video. |
includeCommands | bool | true | Accepted, but not applied in 0.2.4 — commands are always recorded. |
includeAssertions | bool | true | Accepted, but not applied in 0.2.4 — assertions are always recorded. |
deviceLogPollInterval | int (ms) | 1000 | Background poll interval for device logs (min 100), console logs (min 250), and network capture (min 500). |
maxDeviceLogs | int | 2000 | Cap on device-log entries kept per session. |
maxDeviceLogMb | int | 20 | Accepted, but not applied in 0.2.4 — use maxDeviceLogs. |
preferBiDi | bool | true | Try BiDi log.entryAdded before falling back to polling. |
deviceSerial | str | — | Android device serial (as in adb devices). Enables the adb screenrecord video fallback and the mitmproxy network fallback. |
autowrapDriver | bool | true | Auto-wrap drivers found in test fixtures (same as --testrelic-no-autowrap when false). |
testRunId | str | generated | Use a fixed run ID instead of a generated one. |
quiet | bool | false | Reduce console output. |
redactPatterns | list[str] | [] | Extra patterns to redact from the timeline (not settable via testrelic_options — see below). |
redactHeaders | list[str] | [authorization, cookie, set-cookie, x-api-key] | Header names masked in network capture (not settable via testrelic_options). |
redactBodyFields | list[str] | [password, secret, token, apiKey, api_key] | Body field names masked in network capture (not settable via testrelic_options). |
metadata | dict | null | Arbitrary metadata attached to the run (set in the config file). |
cloud | object | — | Cloud upload configuration (set in the config file). |
testrelic_options values are parsed as true/false, whole numbers, or plain strings, so list and object values can't be set there. Put cloud and metadata in .testrelic/testrelic-config.json instead (see Cloud Quickstart); that file also accepts outputPath and htmlReportPath.
CLI flags
Override behavior per-run from the pytest command line:
| Flag | Description |
|---|---|
--testrelic-output PATH | Override the timeline output path. |
--testrelic-disable | Disable the plugin for this run. |
--testrelic-quiet | Reduce console output. |
--testrelic-no-autowrap | Do not auto-wrap drivers found in fixtures. |
Environment variables
| Variable | Purpose |
|---|---|
TESTRELIC_API_KEY | API key for cloud uploads. |
TESTRELIC_CLOUD_ENDPOINT | Cloud endpoint (default https://platform.testrelic.ai/api/v1). |
TESTRELIC_UPLOAD_STRATEGY | batch (default, upload at the end), realtime (stream as tests finish), or both. |
TESTRELIC_CLOUD_TIMEOUT | Upload request timeout in milliseconds (default 30000). |
TESTRELIC_RUN_TYPE | Run-type bucket: smoke, regression, nightly, or ci. |
Screenshot and video policy
screenshotOnEvery controls when screenshots are taken:
off— never.on— capture at the end of every test.on-failure— capture when a test fails (the default).on-every-step— intended to capture after every command; in 0.2.4 per-step capture isn't wired up yet, so it behaves likeon.
Video is opt-in via includeVideoRecording=true. Recording uses Appium screen recording first, falling back to adb screenrecord on Android when deviceSerial is set.
Device logs and network capture
- Device logs (
includeDeviceLogs) are polled in the background everydeviceLogPollIntervalms and sliced per test, capped atmaxDeviceLogsentries. - Network capture (
includeNetworkLogs) uses Chrome DevTools Protocol performance logs on Android and safariNetwork on iOS. - Console logs (
includeConsoleLogs) prefer WebDriver BiDilog.entryAddedwhenpreferBiDi=true, falling back to polling.
mitmproxy fallback
When CDP/safariNetwork capture is not available, an optional mitmproxy fallback can record network traffic on Android. It's used only when the network-proxy extra is installed and deviceSerial is set:
pip install "testrelic-appium[network-proxy]"Redaction
The timeline redacts sensitive data, including Appium-specific command arguments for elementSendKeys, setValueImmediate, and replaceValue. Built-in patterns also mask AWS access keys, bearer tokens, private keys, and credentials embedded in URLs, and network capture masks the redactHeaders / redactBodyFields defaults.
In 0.2.4, redactPatterns can't be set through testrelic_options (a list value is read as a single string and rejected when pytest starts), and the config file doesn't read it either. The built-in patterns always apply.