test: Migrate the test suite from XCTest to swift-testing#105
Merged
Conversation
Ports the test suite to swift-testing (@Suite/@Test/#expect) to align with swift-core, which uses swift-testing throughout. No behavior or coverage change: same assertions and the same network-mock scenarios. - Convert UTF8LineParserTests, EventParserTests, and LDSwiftEventSourceTests from XCTestCase subclasses to @suite types. setUp/tearDown become init/deinit on final-class suites so the "reset works" / "no leftover events or requests" invariants are still enforced after each test (verified that an issue recorded in deinit is attributed to the owning test). - Mark LDSwiftEventSourceTests .serialized: it shares process-global state (URLProtocol registration and the static MockingProtocol.requested sink), which XCTest ran serially and swift-testing would otherwise parallelize. The parser suites use per-test fixtures and stay parallel-safe. - The connectionErrorHandler runs on the URLSession delegate queue, off the test's task, where swift-testing's task-local current-test is not set. Capture what it observes into a lock-protected Box and assert on the test thread instead of calling #expect from the callback. - EventSink swaps XCTFail for Issue.record; it keeps its NSCondition blocking wait, which remains the right fit for the URLProtocol delegate-thread handoff. - Drop the xcpretty pipe from the macOS SwiftPM test action: xcpretty parses XCTest output, not swift-testing, and piping through it without pipefail would garble output and mask failures. Plain `swift test` gates correctly and prints swift-testing's native output.
2d29249 to
69aff96
Compare
tanderson-ld
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the test suite to swift-testing (@Suite/@Test/#expect) to align with
swift-core, which uses swift-testing throughout. No behavior or coverage change:
same assertions and the same network-mock scenarios.
XCTestCase subclasses to @suite types. setUp/tearDown become init/deinit on
final-class suites so the "reset works" / "no leftover events or requests"
invariants are still enforced after each test (verified that an issue recorded
in deinit is attributed to the owning test).
(URLProtocol registration and the static MockingProtocol.requested sink), which
XCTest ran serially and swift-testing would otherwise parallelize. The parser
suites use per-test fixtures and stay parallel-safe.
task, where swift-testing's task-local current-test is not set. Capture what it
observes into a lock-protected Box and assert on the test thread instead of
calling #expect from the callback.
wait, which remains the right fit for the URLProtocol delegate-thread handoff.
XCTest output, not swift-testing, and piping through it without pipefail would
garble output and mask failures. Plain
swift testgates correctly and printsswift-testing's native output.
Note
Low Risk
Changes are limited to tests and CI wiring; production EventSource behavior is not modified.
Overview
Moves the SwiftPM test suite from XCTest to swift-testing (
@Suite/@Test/#expect) with the same scenarios and assertions; library code is unchanged.Suites replace
setUp/tearDownwithinit/deiniton final classes so cleanup checks (e.g. no leftover mock events) still run per test.LDSwiftEventSourceTestsis marked.serializedbecause it shares process-globalURLProtocolregistration and a static mock request sink that XCTest ran serially but swift-testing would parallelize.Tests that assert inside
connectionErrorHandler(URLSession delegate queue) now capture observations in aBoxand#expecton the test thread instead of asserting from the callback.EventSinkreports failures viaIssue.recordinstead ofXCTFail.The SwiftPM GitHub action runs plain
swift testinstead of piping through xcpretty, which only understood XCTest output and could hide failures.Reviewed by Cursor Bugbot for commit 69aff96. Bugbot is set up for automated code reviews on this repo. Configure here.