---
title: "recordFailure(withDescription:inFile:atLine:expected:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestcase/recordfailure(withdescription:infile:atline:expected:)"
---

# recordFailure(withDescription:inFile:atLine:expected:)

Records a failure during text execution.

## Declaration

```swift
func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool)
```

## Parameters

- `description`: A description of the failure.
- `filePath`: The file path to the source file where the failure occurred.
- `lineNumber`: The line number in the source file at filePath where the failure occurred.
- `expected`: doc://com.apple.documentation/documentation/Swift/true if the failure was the result of a failed assertion, doc://com.apple.documentation/documentation/Swift/false if it was the result of an uncaught exception.

## Discussion

Discussion All test assertions use this method to record test failures.

## See Also

### Creating Tests Programmatically

- [init(invocation:)](xctest/xctestcase/init(invocation:).md)
- [init(selector:)](xctest/xctestcase/init(selector:).md)
- [testInvocations](xctest/xctestcase/testinvocations.md)
- [invocation](xctest/xctestcase/invocation.md)
- [invokeTest()](xctest/xctestcase/invoketest().md)
- [record(_:)](xctest/xctestcase/record(_:).md)
- [defaultTestSuite](xctest/xctestcase/defaulttestsuite.md)
