---
title: "XCTExpectFailure(_:enabled:strict:issueMatcher:)"
framework: xctest
role: symbol
role_heading: Function
path: "xctest/xctexpectfailure(_:enabled:strict:issuematcher:)"
---

# XCTExpectFailure(_:enabled:strict:issueMatcher:)

Instructs the test to expect a failure in an upcoming assertion, with parameters to customize expected failure checking and handling.

## Declaration

```swift
func XCTExpectFailure(_ failureReason: String? = nil, enabled: Bool? = nil, strict: Bool? = nil, issueMatcher: ((XCTIssue) -> Bool)? = nil)
```

## Parameters

- `failureReason`: An optional string that describes why the test expects a failure.
- `enabled`: A Boolean value that indicates whether the test checks for the expected failure.
- `strict`: A Boolean value that indicates whether the test reports an error if the expected failure doesn’t occur.
- `issueMatcher`: A block of code that determines whether the test issue fulfills the expected failure.

## See Also

### Expected Failures

- [XCTExpectedFailure](xctest/xctexpectedfailure.md)
- [XCTExpectedFailure.Options](xctest/xctexpectedfailure/options.md)
- [XCTExpectFailure(_:options:)](xctest/xctexpectfailure(_:options:).md)
- [XCTExpectFailure(_:options:failingBlock:)](xctest/xctexpectfailure(_:options:failingblock:).md)
- [XCTExpectFailure(_:enabled:strict:failingBlock:issueMatcher:)](xctest/xctexpectfailure(_:enabled:strict:failingblock:issuematcher:).md)
