# `Cucumber.Attachment`
[🔗](https://github.com/huddlz-hq/cucumber/blob/main/lib/cucumber/attachment.ex#L1)

An attachment recorded during a cucumber run via `Cucumber.attach/4`,
`Cucumber.log/2`, or `Cucumber.link/2`.

Attachments are attributed to the execution that recorded them:

  * `phase` - `:step`, `:before_scenario`, or `:after_scenario` (nil when
    recorded outside the scenario lifecycle, i.e. from a `before_all` or
    `after_all` hook)
  * `step_text`/`step_line` - set when `phase` is `:step`
  * `feature_file`/`scenario_name` - the owning scenario
  * `attempt` - the scenario's 1-based retry attempt (nil when recorded
    outside the scenario lifecycle)

Run-hook attachments (from `before_all`/`after_all`) belong to no
scenario: their scenario fields are nil. With Cucumber Messages output
enabled they are emitted as `attachment` envelopes carrying the hook's
`testRunHookStartedId`, between that hook's `testRunHookStarted` and
`testRunHookFinished` envelopes.

`body` holds text as-is (`encoding: :identity`) or Base64-encoded bytes
(`encoding: :base64`), mirroring the Cucumber Messages attachment
`contentEncoding` field.

# `t`

```elixir
@type t() :: %Cucumber.Attachment{
  attempt: pos_integer() | nil,
  body: String.t(),
  encoding: :identity | :base64,
  feature_file: String.t() | nil,
  filename: String.t() | nil,
  media_type: String.t(),
  phase: :step | :before_scenario | :after_scenario | nil,
  scenario_name: String.t() | nil,
  step_line: non_neg_integer() | nil,
  step_text: String.t() | nil
}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
