<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTFail(_:file:line:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "s:6XCTest7XCTFail_4file4lineySS_s12StaticStringVSutF"
  },
  "title" : "XCTFail(_:file:line:)"
}
-->

# XCTFail(_:file:line:)

This function generates a failure immediately and unconditionally.

```
func XCTFail(_ message: String = "", file: StaticString = #filePath, line: UInt = #line)
```

## Parameters

`message`

An optional description of the assertion, for inclusion in test results.

`file`

The file where the failure occurs. The default is the filename of the test case where you call this function.

`line`

The line number where the failure occurs. The default is the line number where you call this function.

## Discussion

---

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)