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

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

Records a failure during test execution for the test run.

## Declaration

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

## Parameters

- `description`: The description of the failure.
- `filePath`: The file path to the source file where the failure occurred or nil if unknown.
- `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 Don’t call this method before the test run starts or after it stops.
