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

# record(_:sourceLocation:)

Attach an attachment to the current test.

```
static func record(_ attachment: consuming Attachment<AttachableValue>, sourceLocation: SourceLocation = #_sourceLocation)
```

## Parameters

`attachment`

The attachment to attach.

`sourceLocation`

The source location of the call to this function.

## Discussion

When `attachableValue` is an instance of a type that does not conform to
the [`Sendable`](https://developer.apple.com/documentation/swift/sendable)
protocol, the testing library calls its [`withUnsafeBytes(for:_:)`](/documentation/Testing/Attachable/withUnsafeBytes(for:_:))
immediately and records a copy of the resulting buffer instead. If
`attachableValue` throws an error when the testing library calls its
[`withUnsafeBytes(for:_:)`](/documentation/Testing/Attachable/withUnsafeBytes(for:_:)) function, the testing library
records that error as an issue in the current test.

---

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)