---
title: "testCase(_:didFailWithDescription:inFile:atLine:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestobservation/testcase(_:didfailwithdescription:infile:atline:)"
---

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

Notifies the observer when a test case reports a failure.

## Declaration

```swift
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 doc://com.apple.xctest/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.

## See Also

### Observation Methods

- [testBundleWillStart(_:)](xctest/xctestobservation/testbundlewillstart(_:).md)
- [testSuiteWillStart(_:)](xctest/xctestobservation/testsuitewillstart(_:).md)
- [testCaseWillStart(_:)](xctest/xctestobservation/testcasewillstart(_:).md)
- [testCase(_:didRecord:)](xctest/xctestobservation/testcase(_:didrecord:)-4cou6.md)
- [testCase(_:didRecord:)](xctest/xctestobservation/testcase(_:didrecord:)-8k955.md)
- [testCaseDidFinish(_:)](xctest/xctestobservation/testcasedidfinish(_:).md)
- [testSuite(_:didRecord:)](xctest/xctestobservation/testsuite(_:didrecord:)-3rk9k.md)
- [testSuite(_:didRecord:)](xctest/xctestobservation/testsuite(_:didrecord:)-1xjkv.md)
- [testSuite(_:didFailWithDescription:inFile:atLine:)](xctest/xctestobservation/testsuite(_:didfailwithdescription:infile:atline:).md)
- [testSuiteDidFinish(_:)](xctest/xctestobservation/testsuitedidfinish(_:).md)
- [testBundleDidFinish(_:)](xctest/xctestobservation/testbundledidfinish(_:).md)
