XCTExpectFailure(_:enabled:strict:failingBlock:issueMatcher:)
Instructs the test to expect a failure in an assertion in the provided block of code, with parameters to customize expected failure checking and handling.
Declaration
func XCTExpectFailure<R>(_ failureReason: String? = nil, enabled: Bool? = nil, strict: Bool? = nil, failingBlock: () throws -> R, issueMatcher: ((XCTIssue) -> Bool)? = nil) rethrows -> RParameters
- 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.
- failingBlock:
A block of test code and assertions where the test expects a failure.
- issueMatcher:
A block of code that determines whether the test issue fulfills the expected failure.
Return Value
If the failingBlock you provide returns a value or throws an error, the function returns that value or rethrows the error.