Skip to content

Conversation

jerryjrchen
Copy link

@jerryjrchen jerryjrchen commented Oct 2, 2025

empowered to choose Swift Testing when writing new tests or test helpers, as
it will work properly in both types of tests.

We don't propose supporting interoperability for APIs without risk of data loss,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We don't propose supporting interoperability for APIs without risk of data loss,
We don't propose supporting interoperability for APIs which are not lossy without interop,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't not hate the double negative here, but can't think of better wording at the moment :)

@grynspan grynspan changed the title Targeted Interoperability between Swift Testing and XCTest [ST-NNNN] Targeted Interoperability between Swift Testing and XCTest Oct 3, 2025
@grynspan grynspan added the TWG Contains topics under the domain of the Testing Workgroup label Oct 3, 2025
For the remainder of this proposal, we’ll describe test APIs which exhibit this
problem as **lossy without interop**.

This problem risks regressing test coverage for projects which migrate to Swift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This problem" is a bit vague in this context since the problem would actually be the regressed test coverage. Consider rephrasing so that it's clear that the lack of interop is what leads to symptoms/problems X, Y, and Z.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I reworded this whole section for better clarity

from XCTest to Swift Testing. For issue details unique to XCTest, we will
include them as a comment when constructing the Swift Testing issue.

Note that no changes are proposed for the `XCTSkip` API, because they already
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we think of other XCTest features that are explicitly not supported and should be called out here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XCTestAssertion and XCTWaiter, I guess!

We propose supporting the following Swift Testing APIs in XCTest:

- `#expect` and `#require`
- Includes [exit testing][]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Includes [exit testing][]
- Includes `#expect(throws:)`
- Includes [exit testing][]

Assuming #expect(throws:) will work! If it won't work, we need to call that out too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my understanding of that API, we're catching thrown errors and recording issues if not thrown. Since we'd need to add interop support for Swift Testing Issue as part of the default #expect, it seems to me the check throws variant should work too

usage occurs when running Swift Testing tests by turning those warnings into a
`fatalError`.

Configure the interoperability mode when running tests using the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This environment variable affects the behaviour of XCTest API, right? Then I think we want to put it in the XCTEST_ namespace. 🤔

@jerryjrchen jerryjrchen force-pushed the swt-xct-interop branch 3 times, most recently from ff379e8 to 0545e6c Compare October 3, 2025 18:16
Many projects want to migrate from XCTest to Swift Testing, and may be in an
intermediate state where test helpers written using XCTest API are called from
Swift Testing. Today, the Swift Testing and XCTest libraries stand mostly
independently, which means an [`XCTAssert`][XCTest assertions] failure in a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
independently, which means an [`XCTAssert`][XCTest assertions] failure in a
independently, which means an [`XCTAssert()`][XCTest assertions] failure in a

This and the next suggestion are completely nitpickish.

intermediate state where test helpers written using XCTest API are called from
Swift Testing. Today, the Swift Testing and XCTest libraries stand mostly
independently, which means an [`XCTAssert`][XCTest assertions] failure in a
Swift Testing test or an [`#expect`][Swift Testing expectations] failure in an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Swift Testing test or an [`#expect`][Swift Testing expectations] failure in an
Swift Testing test or an [`#expect()`][Swift Testing expectations] failure in an

- [Expected failures][], such as `XCTExpectFailure`: marking a Swift Testing
issue in this way will generate a runtime warning issue.
- [`XCTAttachment`][XCTest attachments]
- [Issue handling traits][]: we will make our best effort to translate issues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this point about traits or about issue handling in general? (Since we're not translating traits.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we're not proposing that you could attach a Swift Testing trait to an XCTest test function. This is about the issue handling trait in a Swift Testing test, and what happens when it's asked to handle a XCTAssert failure.

@stmontgomery stmontgomery added workgroup: needs implementation This proposal needs more implementation work before it can be reviewed workgroup: needs pitch This proposal needs to spend more time in pitch before it can be reviewed labels Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TWG Contains topics under the domain of the Testing Workgroup workgroup: needs implementation This proposal needs more implementation work before it can be reviewed workgroup: needs pitch This proposal needs to spend more time in pitch before it can be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants