<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Mohamed,<div class=""><br class=""></div><div class="">I agree it’s very difficult to test assertions in XCTest today. This approach looks interesting, but I’m not sure how it’s possible to implement within XCTest’s current architecture. Do you have any idea how this would be implemented?&nbsp;</div><div class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Dec 31, 2015, at 1:35 AM, Mohamed Ebrahim Afifi via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Right now, we cannot easily test failed assertions (assert, assertionFailure, precondition, preconditionFailure, fatalError) in our own code without some hacks in the code under test. Like this example&nbsp;<a href="https://github.com/mohamede1945/AssertionsTestingExample" class="">https://github.com/mohamede1945/AssertionsTestingExample</a></div><div class=""><br class=""></div><div class="">So, my suggestion is to add for XCTest something very similar to&nbsp;<b class="">expectCrashLater</b> that is defined here&nbsp;<a href="https://github.com/apple/swift/blob/9b15d03b73b9e8a6dbd3f71b5c78660a359e8e26/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb" class="">https://github.com/apple/swift/blob/9b15d03b73b9e8a6dbd3f71b5c78660a359e8e26/stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb</a></div><div class="">and used in tests like this example&nbsp;<a href="https://github.com/apple/swift/blob/master/validation-test/stdlib/Assert.swift" class="">https://github.com/apple/swift/blob/master/validation-test/stdlib/Assert.swift</a></div><div class=""><br class=""></div><div class="">What do you think?</div><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class="">Best Regards,<div class="">Mohamed Afifi</div></div></div></div></div></div>
</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=U7z7oSqRMSwdl2rYt9JJ4zIFaeg4R-2FxExg9xndDuCbwNbdxz0U2-2FzrvmcSyuDynq9bISO-2BMyFrjnnW4NVXO90-2F86M0Laqvo71eSsSXdvJJdDKBdSeykbEqfIrlJIyw0VBhuZ8Qs71nh07gioa9Yb2UqJPEWye1XOgxvU-2BFTxLOWJMvjZvnku1wDHnFCRntuqfcCttzlCmkRRcPR-2Fd3kgTgNx8Mze5kMsH-2FpL1rxrE0E-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>