Skip to content

fix(test): Parse Swift Testing results for tests without display names - #542

Open
breken-ai wants to merge 2 commits into
getsentry:mainfrom
breken-ai:fix/swift-testing-unquoted-test-names
Open

breken-ai wants to merge 2 commits into
getsentry:mainfrom
breken-ai:fix/swift-testing-unquoted-test-names

Conversation

@breken-ai

Copy link
Copy Markdown

Problem

Swift Testing only quotes a test's name when the test has a display name. For a test written as @Test func fails(), it prints the bare function name:

✔ Test passes() passed after 0.001 seconds.
✘ Test fails() recorded an issue at CountsTests.swift:6:24: Expectation failed: (one() → 1) == 2
✘ Test fails() failed after 0.004 seconds with 3 issues.
✘ Test param(x:) with 3 test cases failed after 0.004 seconds with 1 issue.
➜ Test "Skipped with display name" skipped: "later"

I captured this from xcodebuild test (Xcode 26, Swift Testing 1501) and from swift test (Swift 6.2.3). parseSwiftTestingResultLine and parseSwiftTestingIssueLine only accept quoted names (Test "(.+)"), so every line above except the skip is dropped as unrecognized. The skip is dropped too, because the arrow skip format only accepts an unquoted name. Parameterized issue lines are also missed unless the argument is literally named value: the pattern expects with 1 argument value → ..., but real output is with 1 argument x → 2.

The effect is clearest with swift_package_test, which has no xcresult to fall back on. I ran a package with one passing test, one failing @Test func with 3 issues, one failing display-named test, a parameterized test with one failing case, and two skipped tests. On main, 2 of the 6 test results are recognized and only one failure diagnostic is emitted (the display-named test). The failures in fails() and param(x:) have no location, and their pass/fail results never appear as test-case results.

Fix

  • Result and issue lines accept a bare name ([^\s"]\S*) as well as a quoted display name. The bare form cannot match Test run with ... summary lines, and there is a test for that.
  • The arrow skip format also accepts a quoted display name.
  • Parameterized issue lines accept any argument label (with N argument(s) <label> → <value>).

With the fix, the same output gives 6 test results and all 5 failure diagnostics, with locations.

Running with parallel testing on is unaffected. In that mode xcodebuild prints only Test case 'Suite/name()' ... lines, not the native lines, so nothing is counted twice.

Tests

  • swift-testing-line-parsers.test.ts: bare-name passed, failed and parameterized failed results; quoted arrow skip; bare-name issue lines with and without an argument; summary lines not parsed as results.
  • xcodebuild-event-parser.test.ts: parses Swift Testing results for tests without display names replays the captured xcodebuild lines.

The new tests fail on d13ff0c (7 failed / 59 passed in the two files) and pass with the fix (66/66). The full unit suite passes (243 files, 2599 tests). npm run build, npm run typecheck, npm run lint (0 errors) and prettier --check on the changed files also pass. I did not run the snapshot and smoke suites.

This touches the same parser area as #541 but is independent of it. The two PRs only conflict in CHANGELOG.md.

I wrote this change with AI assistance (Claude) and checked it against real xcodebuild test and swift test output.

breken-ai and others added 2 commits September 29, 2026 18:30
Swift Testing prints the bare function name for tests declared without a
display name, e.g. `✔ Test passes() passed after 0.001 seconds.`. The
result and issue parsers only accepted quoted names, so these lines were
ignored: passes, failures and failure locations for `@Test func name()`
tests never reached progress or the summary.

Accept bare names in result and issue lines, parse quoted names in the
arrow skip format, and accept any argument label in parameterized issue
lines (`with 1 argument x → 2`), not only arguments named `value`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant