I’m using swift-testing and all my view models are marked @MainActor and @Observable. My tests for these view models run slowly, and I suspect it’s because they all execute on the main actor, preventing parallelization.
As a rough comparison, I leveraged AI and rewrote the same tests using XCTest and saw ~50% faster execution. My working theory is that XCTest is benefiting from higher-level parallelism (e.g., process level parallelization), while swift-testing currently isn’t, at least in my setup.
so I guess I have a few questions:
Am I doing something suboptimal in terms of how to use swift-testing to test view models?
Are there any knobs I can turn to increase the level of parallelism with swift-testing?
Swift Testing implements parallelization in-process. Multiprocess parallelization is a future direction we are interested in exploring in the future on platforms where it's possible to implement.
I’m using Xcode locally and xcodebuild in a CI environment.
I had mentioned this to @grynspan on Slack, but I tried the -parallelize-tests-among-destinations flag with the hope that I could at least distribute the test among separate simulators. However, that doesn’t seem to be supported either.
No worries - i asked about this in the #testing channel on iOS Folks early December last year. You suggested that I post here, but I just haven’t gotten around to it until now.