<!--
{
  "availability" : [
    "Swift: 6.3.0 -",
    "Xcode: 26.4.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Issue/record(_:severity:sourceLocation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift Testing",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing5IssueV6record_8severity14sourceLocationAcA7CommentVSg_AC8SeverityOAA06SourceF0VtFZ"
  },
  "title" : "record(_:severity:sourceLocation:)"
}
-->

# record(_:severity:sourceLocation:)

Records an issue that a test encounters while it’s running.

```
@discardableResult static func record(_ comment: Comment? = nil, severity: Issue.Severity = .error, sourceLocation: SourceLocation = #_sourceLocation) -> Issue
```

## Parameters

`comment`

A comment describing the expectation.

`severity`

The severity level of the issue.  The testing library marks the
test as failed if the severity is greater than [`Issue.Severity.warning`](/documentation/Testing/Issue/Severity-swift.enum/warning).
The default is [`Issue.Severity.error`](/documentation/Testing/Issue/Severity-swift.enum/error).

`sourceLocation`

The source location to which the issue should be
attributed.

## Return Value

The issue that was recorded.

## Discussion

Use this function if, while running a test, an issue occurs that cannot be
represented as an expectation (using the [`expect(_:_:sourceLocation:)`](/documentation/Testing/expect(_:_:sourceLocation:))
or [`require(_:_:sourceLocation:)`](/documentation/Testing/require(_:_:sourceLocation:)-5l63q) macros.)

---

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)