# Swift Tests

**URL:** <https://forums.swift.org/t/swift-tests/78067>\
**Category:** Using Swift\
**Created:** [February 24, 2025, 7:01pm UTC](https://forums.swift.org/t/swift-tests/78067 "2025-02-24T19:01:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrsum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rrsum/32/27011_2.png) [@rrsum](https://forums.swift.org/u/rrsum)\
**Post date:** [February 24, 2025, 7:01pm UTC](https://forums.swift.org/t/swift-tests/78067/1 "2025-02-24T19:01:07Z")

</div>

I have a question about swift testing. I found it necessary to rewrite several tests for a library, so I decided to try my hand at swift testing. I put them all in a suite and took what had been in setUpWithError() and put it in init() for the suite. Each test runs fine when executed separately, but the suite fails when I try to run it. A similar procedure with XCTest works fine. It seems to have to do with concurrency. If I make the suite a main actor, it works fine. Could someone explain this situation, and are there other alternatives to declaring a main actor for the suite.

It seems that just replacing XCTest wit Swift Test is not quite. enough.

Rick

---

<div class="post-metadata">

**Author:** ![stephencelis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stephencelis/32/2675_2.png) [@stephencelis](https://forums.swift.org/u/stephencelis)\
**Post date:** [February 24, 2025, 7:24pm UTC](https://forums.swift.org/t/swift-tests/78067/2 "2025-02-24T19:24:08Z")

</div>

Swift Testing runs tests parallel in the same process. XCTest runs tests parallel in their own processes. In the migration docs, the suggestion is to use the `.serialized` trait to match the behavior of XCTest: [https://swiftpackageindex.com/swiftlang/swift-testing/main/documentation/testing/migratingfromxctest#Run-tests-sequentially](https://swiftpackageindex.com/swiftlang/swift-testing/main/documentation/testing/migratingfromxctest#Run-tests-sequentially)

If you want to take advantage of parallelization, you'll need to isolate what is bleeding between tests and control it.

---

<div class="post-metadata">

**Author:** ![rrsum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rrsum/32/27011_2.png) [@rrsum](https://forums.swift.org/u/rrsum)\
**Post date:** [February 24, 2025, 8:07pm UTC](https://forums.swift.org/t/swift-tests/78067/3 "2025-02-24T20:07:19Z")

</div>

Thanks, I missed that.
