An update about Swift Testing in the Swift 6 toolchain

Dearest Swift Testing adopters!

If you happened to download the 2024-08-19 main-branch toolchain, you might have noticed that Swift Testing is included! :partying_face: We're inching closer to adding Swift Testing into the Swift 6 toolchain, and I wanted to let you all know our plans for the Swift Testing package!

We’ll be creating our release/6.0 branch very shortly, in line with the other components of the Swift 6 release. Because Swift Testing will be in the Swift 6 toolchain soon, it won't be necessary for package authors to include it as a package dependency anymore.

So, shortly after the release of the Swift 6 toolchain, we will be creating a final pre-6.0 tag (0.99.0) of the Swift Testing package that deprecates the @Test and @Suite attributes. If you’re including Swift Testing as a package dependency, you’ll see a warning like this one when you use @Test or @Suite:

:warning: ExampleTests.swift:30:4 'Test' is deprecated: Swift Testing is now included in the Swift 6 toolchain. Remove your 'swift-testing' package dependency to silence this warning.

Oh no!

Don't panic! We aren't deprecating the package as a whole. Our intent here is to notify developers that are still using these early/prerelease tags of Swift Testing that they don't need to do so anymore. These deprecations won't be present in the version of Swift Testing included with the toolchain, nor will it be present on future tags corresponding to future prerelease or release versions of the Swift toolchain.

If you wish to continue using Swift Testing 0.x, you can modify your package manifest file to explicitly specify the tagged version you wish to use. Keep in mind that these early/prerelease tags of Swift Testing are not guaranteed to work with future Swift releases.

I still want to try out new features!

When we start working on the next version of Swift in earnest, you'll be able to get the latest version of Swift Testing by downloading a prerelease toolchain. If you want to try out new Swift Testing features on a release toolchain, you'll be able to add a package dependency such as:

.package(
  url: "https://github.com/swiftlang/swift-testing.git",
  from: "700.0.0-latest"
)

Where 700.0.0 would correspond to a hypothetical Swift 7 toolchain release[1]. Note that doing so opts you back into a prerelease version of Swift Syntax as well.


  1. This versioning strategy matches the one used by Swift Syntax. ↩︎

17 Likes

Great, looking forward to using it.

Note that you'll want to add snapshot tags of this repo too, so those like me who build the toolchain from the source snapshot tags know what commit to use. For example, swift-foundation just started adding such snapshot tags, now that it is in Swift 6 also.

I believe Mishal is the guy to talk to about setting that up.

2 Likes

Mishal is in the loop and is helping us with our infrastructure/integration checklist. :slight_smile:

Edit: Nightly snapshots are now being tagged.

1 Like

https://swiftpackageindex.com/swiftlang/swift-testing/main/documentation/testing/temporarygettingstarted

Note

If your package does not explicitly list the testing library as a dependency, pass --enable-experimental-swift-testing to the swift test command to ensure your tests are run.

Does this imply that we should now be able to run swift test without listing swift-testing as an explicit dependency?

Yes, this is the case already for Linux swift:nightly (not nightly-6.0 though) snapshots and toolchains shipped with latest Xcode betas.

1 Like

(We're workin' on it!)

1 Like

Now that Swift 6 is available, we've deployed 0.99.0 as described above.

5 Likes

I love how "Don't panic!" is becoming the unofficial tagline of Swift 6.0 :smile:

Also: Fantastic work on Swift Testing! It is a much appreciated breath of fresh air compared to the somewhat dusty and dated XCTest.

1 Like

The core team are some real hoopy froods that really know where their towels are.

2 Likes

Just created this issue. This is absolutely horrendous :melting_face::

2 Likes

Thanks for filing the issue. I'm not sure that this announcement thread is the right place to share it though. Perhaps a new thread would be a better place to discuss?

ahh hmm just wanted to catch some eyes I guess. Otherwise we can have the discussion somewhere else like in the issue.