You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correctly block @Suite and @Test on XCTest.XCTest and XCTestSuite. (#1456)
This PR ensures that we diagnose if `@Suite` or `@Test` is applied to a
class (or method on such class) that subclasses
[`XCTest.XCTest`](https://developer.apple.com/documentation/xctest/xctest)
or
[`XCTestSuite`](https://developer.apple.com/documentation/xctest/xctestsuite),
not just
[`XCTestCase`](https://developer.apple.com/documentation/xctest/xctestcase).
This change also suppresses the emitted call to the helper function
`__invokeXCTest[Case]Method()` if the suite type is _known_ not to
subclass `XCTest.XCTest` (e.g. because it's a `struct`.) This slightly
improves the performance of non-class suite types (although probably not
measurably so).
Finally, this change improves the emitted diagnostic when `@Test` is
used on a method in an `XCTest.XCTest` subclass such that it explicitly
states the reason why the attribute can't be used:
> 🛑 Attribute 'Test' cannot be applied to a function within class 'C'
because it is a subclass of 'XCTest', 'XCTestCase', or 'XCTestSuite'
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
0 commit comments