Coverage & Test Generation

A pipeline that finds high-coverage paths in real user sessions and turns them into automated test cases.

The coverage and test generation pipeline analyzes RUM sessions in groups to find the paths real users take most often, then turns those paths into session-replay-based automated test cases (Appium and Playwright). Tests come from real production behavior, not synthetic scenarios.

The problem it solves

QA teams design test scenarios by hand, and those scenarios drift far from the paths real users actually take. Mobile automation tests are expensive to maintain, and there is little objective basis for deciding which paths to test first. This pipeline derives priorities from real usage data and delegates both test authoring and UI-change maintenance to agents.

NOTE — v2 plan

This page describes the v2 pipeline plan. The coverage metric and agent composition are settled, but specific behavior and thresholds may change during implementation.

Step-by-step flow

agent-coverage
  1. Session collection — RUM session events are indexed.
  2. Analysis — The Analyzer Agent groups sessions into segments, aggregates screen transitions into funnels and Sankey graphs, and extracts the top-coverage paths.
  3. Test generation — The TC Gen Agent reads the representative session for each path and drafts an executable test script.
  4. Validation — The Validator Agent runs the draft and checks that it matches the key events of the original session.
  5. Registration — Approved scripts are registered in the test catalog and integrated into the CI pipeline.

User behavior coverage

User behavior coverage is a metric defined by Sophonz. Unlike code coverage, which measures whether code executed, user behavior coverage is based on the paths real users take. It extracts the paths most users actually traverse from RUM session data and quantifies what percentage of total real usage those paths cover.

coverage(path) = (sessions containing the path) / (total sessions)

The default priority is coverage * frequency, and the weighting can be customized per organization.

Responsibilities per agent

Analyzer Agent

  • Input — Project, environment, and time range.
  • Process — Groups sessions by device and user segment, aggregates screen transitions into a Sankey graph, normalizes dynamic parameters (/users/123 → /users/:id), and selects the Top-N paths by coverage.
  • Output — A list of paths and a representative session ID for each.

TC Gen Agent

  • Input — A path and its representative session.
  • Process — Reads the session event stream to extract the action sequence and generates platform-specific code (Android/iOS → Appium, Web → Playwright). It inserts retry and wait logic automatically and marks fixture and test-data slots as comments.
  • Goal — Raise user behavior coverage above a configured threshold.

Validator Agent

Runs the draft in an emulator or headless browser, verifies it matches the key events of the original session, and triggers regeneration if it detects flakiness.

Automatic maintenance loop

When a UI change breaks a test, the following loop runs without human intervention.

  1. The failure event is delivered to the orchestrator.
  2. The Analyzer re-extracts paths from the last 7 days of sessions.
  3. The TC Gen Agent regenerates the script.
  4. The Validator re-verifies it.

Security and privacy

  • Sensitive input values in session events follow the masking policy of the RUM session.
  • Generated scripts include only masked placeholders, never real values.
  • The entire pipeline is recorded as a single trace, binding session → path → script → CI result together.