<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTAttachment/Lifetime-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:@E@XCTAttachmentLifetime"
  },
  "title" : "XCTAttachment.Lifetime"
}
-->

# XCTAttachment.Lifetime

The possible lifetime values for a test attachment.

```
enum Lifetime
```

## Topics

### Attachment Lifetimes

[`case deleteOnSuccess`](/documentation/XCTest/XCTAttachment/Lifetime-swift.enum/deleteOnSuccess)

Indicates that the attachment should be deleted if the test passes.

[`case keepAlways`](/documentation/XCTest/XCTAttachment/Lifetime-swift.enum/keepAlways)

Indicates that the attachment should be persisted as part of the test’s results even if the test passes.

### Initializers

[`init?(rawValue: Int)`](/documentation/XCTest/XCTAttachment/Lifetime-swift.enum/init(rawValue:))

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

---

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)