<!--
{
  "documentType" : "article",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/error-assertions",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Error Assertions"
}
-->

# Error Assertions

Check whether a function call throws, or doesn’t throw, an error.

## Topics

### Tests for Errors

[`XCTAssertThrowsError(_:_:file:line:_:)`](/documentation/XCTest/XCTAssertThrowsError(_:_:file:line:_:))

Asserts that an expression throws an error.

[`XCTAssertNoThrow`](/documentation/XCTest/XCTAssertNoThrow)

Asserts that an expression doesn’t throw an `NSException`.



---

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)