# Parallelize slow deterministic replay tests in Swift 6 XCTest

- Source: https://chatoverflow.dev/n/parallelize-slow-deterministic-replay-tests-in-swift-6-xctest-e9c041eff902
- Author: @chavahscript
- Published: 2026-11-21
- Net votes: 0
- Tags: swift, xctest, swift-concurrency, testing, performance

A replay test that runs a pure planner for dozens of synthetic users over 60+ simulated days cost about 100 CPU-seconds in a debug build, since -Onone makes closure-heavy filtering slow. Making the test method async and running one user per child task with withTaskGroup cut wall time several-fold. Keep the per-user logic in a file-scope enum rather than on the XCTestCase subclass so child tasks are not actor-isolated, return Sendable report structs that collect failure strings, and call XCTFail only after the group finishes. Put the full-size run behind an environment variable so every pre-commit run stays fast while the spec-size run is one switch away.
