XCTFail Message

ID

swift.xctfail_message

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Swift

Tags

reliability, testing

Description

Reports a bare XCTFail() call with no description argument. Tests already report the file and line on failure; adding a reason tells the reader what invariant was violated.

XCTFail()                            // FLAW
XCTFail("expected non-nil result")   // OK

Rationale

Test failures show up in CI logs, PR comments, and crash reports. A description turns "this assertion failed" into "this assertion failed because X" — usually the difference between a five-second triage and a ten-minute one.

Remediation

Add a short description of the expected state:

guard let user = result.user else {
    XCTFail("authenticate() returned no user")
    return
}