Selvage SDK

iOS QA SDK: scenario runner, in-app bug reporter and device dashboard

Flow tests and an in-app bug reporter for SwiftUI and UIKit apps, shipped as the Selvage Swift package.

  • •9 Swift package products; none of the code knows which app it tests
  • •Scenarios compile from YAML and run through XCUITest or on the device itself
  • •Bug reports carry a screen recording, network trace, touch trail and crash capture
  • •A dashboard served from inside the app lists, imports and runs scenarios
Private RepositoryThis is a private repository. Its source code on GitHub is visible once the owner grants you access.
9
Products
iOS 17+
Platform
0.15.0
Version
Stable
Status

Tech Stack

SwiftSwiftUIUIKitXCUITestSwift Package Manager

A scenario, step by step

Checklist/ChecklistScreen/01-add-an-item.yamlyaml
  1. appId: com.example.checklist
  2. name: A new item appears at the top of the list and can be ticked off
  3. tags: [checklist, smoke]
  4. ---
  5. - launchApp: {clearState: true}
  6. - assertVisible: checklist_title_label
  7. - tapOn: checklist_add_button
  8. - inputText: {id: item_title_field, text: "Buy oat milk"}
  9. - tapOn: item_save_button
  10. - assertVisible: {id: checklist_item_label, text: "Buy oat milk"}
  11. - tapOn: {id: checklist_item_checkbox, index: 0}
  12. - takeScreenshot: item-ticked-off
Step 1 of 8
A scenario in the Selvage YAML dialect, played on a made-up checklist app. An illustration, not a recording.

How it works

A scenario is written once in YAML, compiled to canonical JSON and played against the app. Every run leaves evidence and a verdict.

Authorscenario YAMLSelvage kernelcompile.py · in-appiOS · SelvageXCUITest or in-appEvidenceredactedReportverdict · files
The same scenario files also run on Android with Shuttle and on the web with Heddle.

A run, step by step

  1. 01

    Write the scenario

    One file holds two YAML documents split by ---: the config (appId, name, tags, seed, mocks, lanes) and the list of steps. It sits at Scenarios/Modules/<Module>/<Screen>/<id>.yaml. Sub-flows live in Common/Shared and are pulled in with runFlow, and Common/compiler.yaml holds the settings both compilers read.

    The dialect's home: SCENARIOS.md documents every step, and a kernel test fails when a step is missing from it.

  2. 02

    Compile and check

    The compiler turns each file into canonical JSON with its sub-flows inlined. An unknown key, command or argument is an error that names file:line:column, prints the line and puts a caret under the fault.

    compile.py on the Mac, ScenarioYAMLCompiler inside the app. parity.sh compiles the catalogue with both and fails on the first byte that differs.

  3. 03

    Gates before anything runs

    Cheap checks come first, so a broken catalogue never costs a build or a device.

    run.sh checks the quarantine list, then the compile, lint, doctor and seal gates and the project's own gates; a failing gate exits 4. On the test lane a health hook can stop the run with exit 3 before the build.

  4. 04

    Seed and launch

    After sub-flows are inlined the first step is launchApp, exactly one per scenario, and an openLink right after it is folded into the launch. The seed (locale, link and the app's own values) travels with the launch. onFlowStart runs before it, onFlowComplete after the steps whether they passed or not.

    The app gets FLOW_SEED, a ScenarioLaunchEnvelope as JSON, and applies what it understands.

  5. 05

    Play the steps

    Each step resolves its selector (id, text, index and the rest) and acts: tap, type, scroll, wait. repeat, retry, runFlow and measure nest, and ${VARIABLES} resolve at run time.

    Mac lane: one xcodebuild run drives several simulator clones in parallel. Device lane: ScenarioDevice plays the same steps inside the app, started from the debug menu or the dashboard.

  6. 06

    Assert

    assertVisible, assertNotVisible, assertCount, assertTrue and assertNetwork check what the screen and the network promised. A failed assertion fails the scenario on that step.

    On failure the runner attaches the accessibility tree and the nearest identifiers it could see.

  7. 07

    Collect evidence, redacted

    While the steps run, each SDK records what happened: screens, network, logs. Secrets are masked before anything is written to disk.

    Per scenario: progress.jsonl, steps/NNN.png, network-trace.jsonl, scenario.mp4 and more, attached to the result bundle. The bug reporter drops the named headers, query items and body keys as each entry is recorded, and storage.json redacts any key nobody classified.

  8. 08

    Verdict and report

    The run ends with a status per scenario and files a person and a machine can both read.

    report.html, summary.md, junit.xml and run.json in a timestamped folder under ~/Desktop/SelvageReport/XCUITestsReport, where latest points at the newest run.

Locally and in CI

SelvageiOS

Locally

A Mac with Xcode, a simulator, Python 3 and PyYAML. run.sh is Tools/scenario-runner/run.sh in the Selvage checkout, run from the project root.

run.sh check
run.sh --lane mock --only 01-sign-in
run.sh --file ~/Desktop/draft.yaml --domain Login
run.sh device <link> --file x.yaml
xcodebuild test -scheme Selvage-Package -destination 'platform=iOS Simulator,name=iPhone 17 Pro'
  • check lints the catalogue and compiles it with no simulator and no build.
  • --only runs catalogued scenarios, which reach the run through a build. --file plays one YAML on the bundle already built, with no rebuild: the fastest loop while writing.
  • device runs a file on a phone through the in-app dashboard, whose link carries the token. On a device the dashboard is off until Scenario Runner > Settings > Dashboard turns it on. It listens on port 8420, or the first free port above it, and draws a new token on every launch of the app; the socket and the artefact route answer 401 without it.
  • The xcodebuild line runs the package's own tests.
In CI
No workflow file

The repository has no CI workflow. Its own guard is an opt-in pre-push hook (core.hooksPath .githooks) that runs the scrub gate with --require-list. The runner's README describes the job for a Mac agent with Xcode and a simulator runtime, and leaves the CI system to the host.

python3 -m pip install --user pyyaml
Tools/scenario-runner/run.sh --lane test --env <environment>/<module> --domain Checkout --no-video --allow-busy
  • Exit 1 means scenarios failed (unstable). Every other non-zero exit means no verdict.
  • Keep junit.xml, report.html and the run folder as build artifacts, each .xcresult zipped beside the page.
  • Give the agent a persistent run root (FLOW_RUN_ROOT): history.jsonl, findings.json and flakes.json carry state from one run to the next.
  • Hook secrets come from the CI's secret store, never as an argument.
  • A quarantined scenario (at most five, each with a ticket and an expiry date) still runs and reports but does not fail the suite. Past its date the run refuses to start.
Exit status
  • 0 every scenario passed
  • 1 scenarios failed
  • 2 the build failed
  • 3 infrastructure
  • 4 a gate failed
  • 130 interrupted

Only 0 and 1 are a verdict; 2, 3, 4 and 130 are not

What Selvage adds

  • The scenario kernel: the YAML dialect, compile.py and the parity check against the in-app compiler
  • Two runners: XCUITest from outside the app, and ScenarioDevice from inside it
  • A run orchestrator: gates, parallel simulator clones, video per scenario, report.html and junit.xml
  • An in-app bug reporter: recording, network trace, touch trail, crash and hang capture, one zip
  • A dashboard served from inside the app, and a relay that lets a server anywhere drive the device

Features

Scenario Runner

Scenarios written in a YAML dialect compile to one wire format.

  • •ScenarioTestRunner interprets them under XCUITest
  • •ScenarioDevice runs the same steps inside the app, without XCTest
  • •Seeds, selectors and evidence travel with each run

In-App Bug Reporter

BugReport packs what a tester saw into one archive.

  • •Screen recording, network trace and touch trail
  • •Crash and hang capture, storage snapshot
  • •Share sheet and a delivery outbox, with an optional Jira client

Device Dashboard

ScenarioDashboard serves a page and a WebSocket from inside the app.

  • •A browser lists, imports and runs scenarios
  • •Each step is followed live
  • •A relay lets a server anywhere drive the device

Privacy & terms