<!--
{
  "availability" : [

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

# XCTAssertThrowsSpecificNamed

Asserts that an expression throws a specific NSException with a specific name.

```
#define XCTAssertThrowsSpecificNamed(expression, exception_class, exception_name, ...)
```

## Parameters

`expression`

An expression.

`exception_class`

The class of the exception.

`exception_name`

The name of the exception.

`…`

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 <doc://com.apple.documentation/documentation/Foundation/NSException> of class `exception_class` with a name of `exception_name`.

---

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)