test(integration): migrate IntegrationTests to Swift Testing (Phase 6)#1097
Open
grdsdev wants to merge 1 commit into
Open
test(integration): migrate IntegrationTests to Swift Testing (Phase 6)#1097grdsdev wants to merge 1 commit into
grdsdev wants to merge 1 commit into
Conversation
Converts all 10 files in Tests/IntegrationTests from XCTest to Swift Testing (@Suite/@test), per the SDK-435 migration plan and the Phase 0 conventions decided in SDK-1247. - XCTestCase setUp's XCTSkipUnless(INTEGRATION_TESTS) becomes a @suite(.enabled(if:)) trait, evaluated once per suite instead of once per test. - setUp/tearDown become init()/deinit() throughout. Files with only read-only shared state (Postgrest x4, PostgrestIntegrationTests, AuthClientIntegrationTests, StorageClientIntegrationTests) convert to structs. StorageFileIntegrationTests and RealtimeIntegrationTests need real async teardown (delete a bucket / disconnect channels), so they stay classes with a deinit that fires the cleanup in a best-effort detached Task, mirroring the old try?-swallowed tearDown semantics. - RealtimeIntegrationTests additionally needs @suite(.serialized) because it swaps the process-global `_clock` seam per test (mirrors the Phase 4 PostgrestBuilderTests precedent), and Sendable conformance on the class since withMainSerialExecutor's closure parameter is @sendable outside DEBUG/Concurrency-availability builds. - No Mocker/Replay involved — these tests hit a real local Supabase instance, so Phase 5's (AuthTests) still-in-progress Replay work is unrelated to this phase. - Moves IntegrationTests out of the blanket Swift 5 language-mode pin into full Swift 6 mode, matching production targets' strict- concurrency settings. No Sendable/isolation diagnostics required fixes beyond RealtimeIntegrationTests above. Linear: SDK-1253
Coverage Report for CI Build 28980049471Coverage increased (+0.03%) to 83.252%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Summary
Migrates all 10 files in
Tests/IntegrationTestsfrom XCTest to Swift Testing (@Suite/@Test), per the SDK-435 migration plan and the Phase 0 conventions decided in SDK-1247. This target has the heaviestsetUp/tearDownusage in the repo (11 total) and orchestrates a real local Supabase instance rather than mocking, so it needed its own lifecycle patterns rather than reusing Phase 2-4's Mocker→Replay work (unrelated — no Mocker/Replay usage here at all).Changes
XCTSkipUnless(INTEGRATION_TESTS)in everysetUpbecomes a@Suite(.enabled(if:))trait, evaluated once per suite instead of once per test method.setUp/tearDownbecomeinit()/deinit(). Files with only read-only shared state per test (the 4 Postgrest files,PostgrestIntegrationTests,AuthClientIntegrationTests,StorageClientIntegrationTests) convert tostructs — no teardown needed.StorageFileIntegrationTestsandRealtimeIntegrationTestsneed real async teardown (delete a test bucket / disconnect realtime channels), so they stayfinal classwith adeinitthat fires cleanup in a best-effort detachedTask, mirroring the originaltry?-swallowedtearDownsemantics (documented inline — this is an accepted tradeoff for ephemeral local test resources, not correctness-critical).RealtimeIntegrationTestsadditionally needs@Suite(.serialized)because it swaps the process-global_clockseam (Sources/Helpers/_Clock.swift) per test — mirrors the Phase 4PostgrestBuilderTestsprecedent — plusSendableconformance on the class sincewithMainSerialExecutor's closure parameter is@Sendableoutside DEBUG/Concurrency-availability builds under Swift 6 strict checking.AuthClientIntegrationTests' customXCTAssertAuthChangeEventshelper (built onXCTestExpectation) is replaced with aLockIsolated+ short polling loop, since Swift Testing has no direct expectation-fulfillment equivalent.IntegrationTestsout of the blanket Swift 5 language-mode pin (Package.swift) into full Swift 6 mode, matching production targets'swiftSettings. No otherSendable/isolation diagnostics needed fixing beyond theRealtimeIntegrationTestscase above.Test plan
swift build --target IntegrationTestscompiles clean under full Swift 6 mode.swift test --filter IntegrationTests: all 8INTEGRATION_TESTS-gated suites (Postgrest x4,PostgrestIntegrationTests,AuthClientIntegrationTests,StorageClientIntegrationTests,StorageFileIntegrationTests) correctly skip via the new.enabled(if:)trait — confirms that gate is equivalent to the old per-testXCTSkipUnless.RealtimeIntegrationTestsfails in this environment withCancellationError(no local Supabase instance reachable) — this is pre-existing: itsXCTSkipUnlesswas already commented out in the original XCTest file (predates this PR), so it has always attempted a live connection unconditionally. Not a regression from this migration. Full live verification (./scripts/test-integration.shagainstsupabase start) needs a local Supabase instance and wasn't run in this environment.Linear
Closes SDK-1253