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

Chris Hanson chanson at apple.com
Wed Jan 13 18:52:41 CST 2016


Thanks, everyone, for all of the feedback.

I sent this proposal out as more of a “heads up” that we were planning to make these changes and get feedback in advance of that, so we won’t be taking this through the full proposal process. That said, here’s what we’re going to be doing:

1. We’re going to let test methods throw, and treat those as unexpected failures, as planned.

2. We’re going to let test assertion expressions throw, and treat those as unexpected failures, as planned. We recognize that this will result in slightly different style in tests versus in regular code, but the convenience and reduction in boilerplate makes this worthwhile.

3. We’re going to add the XCTAssertThrowsError assertion, incorporating Kevin Ballard’s suggestion for how to avoid the “_ = blah()” in its expression.

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.

We’re going to start landing these changes today, so thanks again for all of your attention and feedback!

  -- Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160113/420a3e8b/attachment.html>


More information about the swift-corelibs-dev mailing list