Exceptions thrown from XCTest do not report failure location
| Originator: | brian.king | ||
| Number: | rdar://30667146 | Date Originated: | 2/22/2017 |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | |
| Classification: | Feature | Reproducible: | Yes |
Area:
Something not on this list
Summary:
XCTest test methods can throw, but the location of the thrown errors is not reported. This is understandable given the limitations of #file and #line, but it is still disappointing. Instead, I have to wrap all of my throwing in a function like:
```swift
func AssertNoError<T>(_ expression: @autoclosure (Void) throws -> T, message: String = "Unexpected Error", file: StaticString = #file, line: UInt = #line) throws -> T {
do {
return try expression()
}
catch {
XCTFail(message, file: file, line: line)
throw error
}
}
```
Steps to Reproduce:
throw an exception in a test in an XCTest
Expected Results:
Xcode should be able to point to the line that generated the error
Actual Results:
Xcode points to the line of the function
Version:
Xcode 8.3 beta 3
Notes:
Configuration:
XCTest
Attachments
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!