---
title: "record(_:named:sourceLocation:)"
framework: testing
role: symbol
role_heading: Type Method
path: "testing/attachment/record(_:named:sourcelocation:)"
---

# record(_:named:sourceLocation:)

Attach a value to the current test.

## Declaration

```swift
static func record(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation)
```

## Parameters

- `attachableValue`: The value to attach.
- `preferredName`: The preferred name of the attachment to use when saving it. If nil, the testing library attempts to generate a reasonable filename for the attached value.
- `sourceLocation`: The source location of the call to this function.

## Discussion

Discussion When attachableValue is an instance of a type that does not conform to the Sendable protocol, the testing library calls its 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:_:) function, the testing library records that error as an issue in the current test. This function creates a new instance of Attachment and immediately attaches it to the current test.
