[swift-evolution] Proposal: XCTest Support for Swift Error Handling

Jérôme Duquennoy jerome+swift at duquennoy.fr
Thu Jan 14 13:31:46 CST 2016


> 4. We’re not going to add the ability for XCTAssertThrowsError to check that a specific error was thrown. This could definitely be useful but would require the function to take an ErrorType instance that also conforms to Equatable. We need to think about that some more before making such a change. Fortunately this sort of addition will be straightforward to put in via an overload or default argument, so if we choose to do it later, it shouldn’t break any code that starts to adopt XCTAssertThrowsError.

Wouldn't it be possible to have XCTAssertThrowsError return the thrown error, so that the dev can do it's own test (validating an error code for exemple) ?
This would be fairly easy to implement (see the code I proposed on the 11th), and very flexible (it allows any dev to validate whatever he wants in its custom error type).

Jérôme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160114/84d87024/attachment.html>


More information about the swift-evolution mailing list