Skip to content

Migrate the test suite from XCTest to Swift Testing - #266

Merged
kylebrowning merged 3 commits into
mainfrom
test/swift-testing-migration
Oct 8, 2026
Merged

kylebrowning merged 3 commits into
mainfrom
test/swift-testing-migration

Conversation

@kylebrowning

@kylebrowning kylebrowning commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Converts every test file to Swift Testing. Rebased onto main after #262 through #265 merged, with the tests those PRs added converted as well.

What changed

  • XCTestCase classes are now struct suites with @Test functions, #expect, and #require. Multi-word test names use raw identifiers in sentence case.
  • Swift Testing has no async teardown, so server-backed tests use scoped fixtures in Tests/APNSTests/Helpers/TestFixtures.swift. withClient, withBroadcastClient, withRawHTTPClient, and withServer start the mock server and client, run the test body, and shut both down even on failure. Each test gets its own server, so the suite runs fully in parallel.
  • The JWT private key and device token constants that were copied into seven files now live in TestFixtures.
  • Looped assertions became @Test(arguments:) parameterized tests: push types, priorities, device token shapes, error reasons, interruption levels, and the forced-error-response cases for both clients.
  • as! and ! unwraps in tests became try #require.
  • The Swift 5.10 CI jobs are removed. Swift Testing and raw identifiers need a 6.x toolchain. Projects still on 5.10 can pin to an earlier tag.

Results

Before After
Test functions 164 160
Executed test cases 164 195

The function count dropped because loops collapsed into parameterized tests. The case count rose because each argument now runs and reports as its own case.

Suites are structs with @test functions and #expect/#require. Server-backed
tests use scoped fixtures in TestFixtures that start and shut down the mock
server and client per test, replacing setUp/tearDown. Looped assertions became
parameterized tests. The duplicated JWT key and device token constants now
live in TestFixtures.
@kylebrowning
kylebrowning force-pushed the test/swift-testing-migration branch from 592f86a to bbf71a1 Compare October 8, 2026 15:30
Swift Testing needs a 6.x toolchain. The 5.10 jobs keep verifying the library
compiles but no longer run the test target.
Swift Testing needs a 6.x toolchain. Earlier tagged releases remain available
for projects still on 5.10.
@kylebrowning
kylebrowning merged commit d0b6443 into main Oct 8, 2026
4 checks passed
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