<!--
{
  "availability" : [
    "*: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTestObserver/testCaseDidFail(_:withDescription:inFile:atLine:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTestObserver(im)testCaseDidFail:withDescription:inFile:atLine:"
  },
  "title" : "testCaseDidFail(_:withDescription:inFile:atLine:)"
}
-->

# testCaseDidFail(_:withDescription:inFile:atLine:)

Notifies the observer when a test case fails.

```
func testCaseDidFail(_ testRun: XCTestRun!, withDescription description: String!, inFile filePath: String!, atLine lineNumber: Int)
```

## Parameters

`testRun`

The test run object that calls this method.

`description`

A string description of the failed test.

`filePath`

A string that represents a file path to a source code file when the test encounters a failure.

`lineNumber`

An integer value that represents the line number in the source code file when the test encounters a failure.

## 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)