[swift-evolution] Proposal: XCTest Support for Swift Error Handling
mferris at apple.com
Thu Jan 14 13:34:56 CST 2016
Do you think that approach has a specific advantage over the current approach where the thrown error is passed into the optional block parameter?
They seem more or less equal in what they allow you to accomplish and I kind of like the scoping of the code to check the error within the block associated with the assert that catches the throw…
> On Jan 14, 2016, at 11:31 AM, Jérôme Duquennoy via swift-evolution <swift-evolution at swift.org> wrote:
>> 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).
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution