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
Add experimental SPI to cancel a running test. (#1284)
This PR introduces `Test.cancel()` and `Test.Case.cancel()` which cancel
the current test/suite and the current test case, respectively. For
example:
```swift
@test(arguments: [Food.burger, .fries, .iceCream])
func `Food truck is well-stocked`(_ food: Food) throws {
if food == .iceCream && Season.current == .winter {
try Test.Case.cancel("It's too cold for ice cream.")
}
// ...
}
```
These functions work by cancelling the child task associated with the
current test or test case, then throwing an error to end local execution
early. Compare `XCTSkip()` which, in Swift, is just a thrown error that
the XCTest harness special-cases, or `XCTSkip()` in Objective-C which
actually throws an exception to force the caller to exit early.
Resolves#120.
Resolves#1289.
Resolves rdar://159150449.
### 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.
stringValue:"Test case passing \(arguments.count.counting("argument"))\(testCase.labeledArguments(includingQualifiedTypeNames: verbosity >0)) to \(testName) failed after \(duration)\(issues.description)."
stringValue:"Test case passing \(arguments.count.counting("argument"))\(testCase.labeledArguments(includingQualifiedTypeNames: verbosity >0)) to \(testName)passed after \(duration)\(issues.description)."
576
+
symbol:symbol,
577
+
stringValue:"Test case passing \(arguments.count.counting("argument"))\(testCase.labeledArguments(includingQualifiedTypeNames: verbosity >0)) to \(testName)\(verbed) after \(duration)\(issues.description)\(cancellationComment)"
0 commit comments