Hi everyone,
I wanted to give an update about swift-testing and discuss our plans for declaring the first stable version.
We announced swift-testing last September as a new open source package intended to rethink and modernize testing Swift software. In the announcement forum post, we publicized the GitHub repo and shared a draft Vision document outlining our philosophy behind the project and mentioning various design considerations and potential future directions. We received over a hundred replies to that post with thoughtful feedback and enthusiasm, so I'd like to thank everyone who participated there and has engaged with us on the project thus far.
Project status
Since its initial introduction, swift-testing has been considered experimental. We gave it this designation because we knew it was missing some important functionality and lacked integration with common tools like Swift Package Manager. It would take more time to deliver those pieces, but we wanted to begin soliciting feedback as those efforts got underway.
The project's experimental status was always intended to be temporary, of course; it was meant to discourage adoption in production codebases until the project was more stable and supporting work had landed, while prompting discussion about the core concepts. We have published several tags of the package so far (e.g. 0.7.0, the latest as of this writing), and have intentionally chosen pre-1.0 version numbers to reflect its unstable status.
Recent progress
In recent months we have made significant progress towards lifting the experimental label and declaring the first stable version:
-
SwiftPM integration: @grynspan has landed experimental support in Swift Package Manager for building and running swift-testing style tests, alongside any existing XCTests. This is included in recent Swift 6.0 development snapshot toolchains, and is enabled automatically in packages which declare an explicit dependency on swift-testing.
Directly integrating this way renders the
XCTestScaffold
compatibility shim unnecessary, so there are fewer barriers to start writing tests and the console output is easier to understand. See the updated Getting Started documentation for the latest usage instructions. -
Integration with other tools and IDEs: One of the project's goals stated in the Vision document is to integrate with IDEs and tools beyond SwiftPM. To support this, my colleague @dennis added experimental private APIs for receiving structured result data. These "snapshot" types, along with related private APIs for programmatically driving test execution, are intended to eventually facilitate direct integration with IDEs like VSCode—a topic we've begun discussing on the Forums.
-
Macro improvements: swift-testing relies on Swift macros in several ways, including for test function declaration using
@Test
. Since its introduction, there have been some known limitations with this macro's implementation which require information about the surrounding usage context to resolve.Thankfully, these limitations have now been resolved: swift-syntax introduced a new API for macros to retrieve their lexical context, which swift-testing has adopted, and we've now been able to remove workarounds and surface more helpful diagnostics.
These are in addition to many other refinements to expectation and parameterized testing APIs, documentation, and more.
Achieving stability
swift-testing is getting closer to production-ready. With that in mind, we intend to align the first stable release of swift-testing with Swift 6.0. This means that a Swift 6 toolchain and swift-syntax version 600 or later will soon be required. Using swift-testing to validate code built using the Swift 5 language mode will still be supported, however.
As we continue to stabilize the project, we will soon begin two efforts worth mentioning:
-
Vision document review: We aspire for swift-testing to succeed XCTest as the official, default testing solution in the Swift ecosystem. To that end, we plan to revise our draft Vision document based on feedback and lessons learned during the project's first few months and submit it for review by the Swift Core Team. If this vision is accepted, we will propose promoting the currently-experimental SwiftPM integration to an officially supported feature starting in Swift 6.
-
Public API audit: Before declaring a stable version, we need to ensure we are confident about the design of the package’s public APIs. We have landed some exploratory work on APIs and features which aren't mature enough yet to be suitable for inclusion in the first stable version, so we will soon begin auditing all APIs in the package and lowering some to experimental API or removing them completely.
Conversely, some experimental APIs have been added which we believe may be important and mature enough to merit inclusion in the first stable version. We will review those and propose elevating them to public API, using our newly-added feature proposal template.
We look forward to swift-testing reaching stability and inviting wider adoption starting in Swift 6. Please let us know in this thread if you have questions or comments about these upcoming plans.