---
title: XCTAttachment.Lifetime.deleteOnSuccess
framework: xctest
role: symbol
role_heading: Case
path: xctest/xctattachment/lifetime-swift.enum/deleteonsuccess
---

# XCTAttachment.Lifetime.deleteOnSuccess

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

## Declaration

```swift
case deleteOnSuccess
```

## Mentioned in

Adding Attachments to Tests, Activities, and Issues

## Discussion

Discussion XCTAttachment.Lifetime.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 property to XCTAttachment.Lifetime.keepAlways after attachment initialization.

## See Also

### Attachment Lifetimes

- [XCTAttachment.Lifetime.keepAlways](xctest/xctattachment/lifetime-swift.enum/keepalways.md)
