<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTAssertThrows",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:@macro@XCTAssertThrows"
  },
  "title" : "XCTAssertThrows"
}
-->

# XCTAssertThrows

Asserts that an expression throws an `NSException`.

```
#define XCTAssertThrows(expression, ...)
```

## Parameters

`expression`

An expression.

`…`

An optional description of the failure. A literal <doc://com.apple.documentation/documentation/Foundation/NSString>, optionally with string format specifiers.

## Discussion

This function generates a failure if `expression` doesn’t throw an exception.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)