<!--
{
  "availability" : [

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

# XCTAttachment.Lifetime.deleteOnSuccess

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

```
case deleteOnSuccess
```

## Discussion

[`XCTAttachment.Lifetime.deleteOnSuccess`](/documentation/XCTest/XCTAttachment/Lifetime-swift.enum/deleteOnSuccess) is the default lifetime for all new attachments. This lifetime indicates that an attachment should be discarded if its test passes successfully, to save on storage space.

To persist an attachment even when its test passes, set the attachment’s [`lifetime`](/documentation/XCTest/XCTAttachment/lifetime-swift.property) property to [`XCTAttachment.Lifetime.keepAlways`](/documentation/XCTest/XCTAttachment/Lifetime-swift.enum/keepAlways) after attachment initialization.

---

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)