Skip to content

refactor(ios-runner): move ~3.9k lines of inline unit tests out of production Swift files; split CommandExecution under 1,000 lines #2792

Description

@thymikee

Purpose

About 3,900 lines of runner unit tests are compiled into production source files under #if AGENT_DEVICE_RUNNER_UNIT_TESTS. They are stripped from packaged source (src/__tests__/apple-runner-package-source.test.ts:34-35), so this is about source size and readability, not binary size. The biggest cases (paths under apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/, at 01328de411):

File Total lines Inline test lines
RunnerTests+CommandExecution.swift 2,856 ~786
RunnerTests+AXSnapshotFallback.swift ~549
RunnerTests+SnapshotCapturePlan.swift ~471
RunnerTests+CommandJournal.swift ~334
RunnerTests+Snapshot.swift ~239
RunnerTests+PrivateAXPresentation.swift ~206

RunnerTests+CommandExecution.swift breaks the 1,000-line rule in AGENTS.md. Tests are also meant to mirror source files one to one. UnitTests/ (26 files) already exists as the home for these tests.

Required behavior

  • Move each inline test block to UnitTests/RunnerTests+<SourceName>Tests.swift. Keep the same test names and the same #if guard. Widen private to internal only where a moved test needs it.
  • Do this as a pure move: no test logic changes, one PR per source file or a small batch. Pure moves carry their tests unchanged, as AGENTS.md requires.
  • After the moves, split RunnerTests+CommandExecution.swift under 1,000 lines along command families (tap/press, scroll/drag, type, screenshot/record). The splits are pure moves too.

Completion conditions

  • grep -c AGENT_DEVICE_RUNNER_UNIT_TESTS on each production file (not under UnitTests/) returns 0, or only guards test seams, not whole test blocks.
  • wc -l apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift is under 1,000, and so is every file split out of it.
  • pnpm check:xctest-selection and pnpm check:packaged-runner-swift are green. The macOS host lane test count is the same before and after; paste both counts in the PR.

Follow-up (not part of this issue)

Move the pure policies (tap point, scroll viewport, keyboard band, journal, commit progress) into a SwiftPM package, following apple/snapshot-presentation, and test them with Swift Testing @Test(arguments:) against contracts/fixtures.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions