<!--
{
  "availability" : [

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

# XCTAssert(_:_:file:line:)

Asserts that an expression is true.

```
func XCTAssert(_ expression: @autoclosure () throws -> Bool, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line)
```

## Parameters

`expression`

An expression of Boolean type.

`message`

An optional description of a failure.

`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

This function generates a failure when `expression == false` and is equivalent to [`XCTAssertTrue(_:_:file:line:)`](/documentation/XCTest/XCTAssertTrue(_:_:file:line:)).

---

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)