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

# testCase(_:didFailWithDescription:inFile:atLine:)

Notifies the observer when a test case reports a failure.

```
optional func testCase(_ testCase: XCTestCase, didFailWithDescription description: String, inFile filePath: String?, atLine lineNumber: Int)
```

## Parameters

`testCase`

The test case that reported a failure. Additional information about the test case can be retrieved from the test case’s associated [`XCTestRun`](/documentation/XCTest/XCTestRun).

`description`

A textual description of the failure.

`filePath`

The path to the file in the failure occurred, or `nil` if the file path is unknown.

`lineNumber`

The line number on which the failure was reported.

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