title: Testing assertion in Swift
body: <p>I'm writing unit tests for a method that has an assertion. The Swift Language guide recommends using assertions for "invalid conditions":</p>
  
  <blockquote>
    <p>Assertions cause your app to terminate and are not a substitute for
    designing your code in such a way that invalid conditions are unlikely
    to arise. Nonetheless, in situations where invalid conditions are
    possible, an assertion is an effective way to ensure that such
    conditions are highlighted and noticed during development, before your
    app is published.</p>
  </blockquote>
  
  <p>I want to test the failure case.</p>
  
  <p>However, there is not <code>XCTAssertThrows</code> in Swift (as of Beta 6). How can I <strong>write an unit test</strong> that tests that an assertion fails?</p>
  
  <p><em>Edit</em></p>
  
  <p>As per @RobNapier's suggestion, I tried wrapping <code>XCTAssertThrows</code> in an Objective-C method and calling this method from Swift. This doesn't work as the macro does not catch the fatal error caused by <code>assert</code>, and thus the test crashes.</p>