# What you need to know before migrating to Swift Testing

**URL:** <https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005>\
**Category:** Community Showcase\
**Tags:** concurrency, swift, testing, xctest, swift-testing\
**Created:** [July 9, 2025, 4:09am UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005 "2025-07-09T04:09:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![soumyamahunt](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/soumyamahunt/32/23427_2.png) [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Post date:** [July 9, 2025, 4:09am UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/1 "2025-07-09T04:09:36Z")

</div>

Hi Everyone.

I have written a post on medium going through some of the gotchas you might face when migrating to Swift Testing from XCTest: [What you need to know before migrating to Swift Testing | by Soumya Mahunt | Jul, 2025 | Medium](https://medium.com/@soumyamahunt/what-you-need-to-know-before-migrating-to-swift-testing-b9c1d749ebd5)

Do check this out and let me know your thoughts. What other challenges you have faced when migrating to Swift Testing?

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [July 9, 2025, 2:12pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/2 "2025-07-09T14:12:24Z")

</div>

Thanks for the write-up! If you'd be interested in helping us improve [Migrating a test from XCTest | Apple Developer Documentation](https://developer.apple.com/documentation/testing/migratingfromxctest), we do take PRs. 😃

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [July 9, 2025, 2:40pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/3 "2025-07-09T14:40:41Z")

</div>

Terrific article, thank you @soumyamahunt!

I had two responses to recommendations in your post for your consideration below. (I also added a version of this response to the Medium post directly.)

Re: " **Challenge #1: Assertions Don’t Work Outside of a Task Context**", you can technically continue using `DispatchQueue` or concurrency patterns other than Swift concurrency. However, when doing so you must be careful to place the expectations (such as `#expect(...)`) within the main scope of the `@Test` function so that they are called from its Task. So you don't necessarily have to refactor or stop using `DispatchQueue` right away or ever, but expectations need to occur in the right scope. I realize that sometimes it can be difficult to confine expectations to the main test function scope and it's easier to place them in a closure invoked by a dispatch queue, so it's a case-by-case decision.

Re: " **Challenge #3: Inheriting Suites Doesn’t Inherit Its Tests**", it is true tests from superclasses do not inherit currently. However, Swift Testing encourages an alternative pattern called **Parameterized Testing** which serves a similar role by allowing a single `@Test` function to be invoked multiple times with differing inputs. Conceptually, a parameterized test solves a similar need as test inheritance did in XCTest. If you're migrating from this pattern in XCTest, it may be best to use a single suite type and pass a test within that suite a collection of arguments whose elements represent the inputs to the test which were previously specified via different subclasses.

It's great to see these kinds of nuances being explored and discussed, so thank you again for the writeup.

---

<div class="post-metadata">

**Author:** ![soumyamahunt](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/soumyamahunt/32/23427_2.png) [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Post date:** [July 10, 2025, 1:15pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/4 "2025-07-10T13:15:10Z")

</div>

Thanks @grynspan, will try to come up with a PR for the documentation update.

---

<div class="post-metadata">

**Author:** ![soumyamahunt](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/soumyamahunt/32/23427_2.png) [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Post date:** [July 10, 2025, 1:18pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/5 "2025-07-10T13:18:38Z")

</div>

Thank you @smontgomery, I briefly looked into parameterized testing as a workaround. But since the XCTestCase classes I was converting had around 50-100 test methods I preferred to keep the tests as part of XCTest for now. I would love if Suite inheritance/parameterization at the Suite level is supported as well.

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [July 10, 2025, 4:51pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/6 "2025-07-10T16:51:32Z")

</div>

> [@soumyamahunt](#):
>
> I would love if Suite inheritance/parameterization at the Suite level is supported as well.

This comes up fairly frequently and we are interested in solving the problem, but it's not currently technically feasible. ~~See e.g. [Paramaterised Suites? - #2 by grynspan](https://forums.swift.org/t/paramaterised-suites/78305/2) .~~ Actually, that's probably not a great example as that thread deals with a different definition of "parameterized suite." 🤦‍♂️

Anyway… today, syntax-based macros are not able to give us enough context to correctly expand `@Test` within a parameterized suite type.

---

<div class="post-metadata">

**Author:** ![smontgomery](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/smontgomery/32/965_2.png) [@smontgomery](https://forums.swift.org/u/smontgomery)\
**Post date:** [July 10, 2025, 4:58pm UTC](https://forums.swift.org/t/what-you-need-to-know-before-migrating-to-swift-testing/81005/7 "2025-07-10T16:58:29Z")

</div>

> [@soumyamahunt](#):
>
> I briefly looked into parameterized testing as a workaround. But since the XCTestCase classes I was converting had around 50-100 test methods I preferred to keep the tests as part of XCTest for now.

Understandable, sure. It does require a bit more effort/time to do this conversion.

That being said, when it comes to _recommendations_ given to others (such as in your Medium post), I suggest most users first consider adopting the parameterized test feature in this scenario, since it results in a better experience overall. If you're interested, I'd encourage you to mention parameterized testing in that section of your post, at the very least, to ensure readers are aware of it and understand that it's intended for this purpose.
