Hello Swift enthusiasts! I'm looking for feedback from you all about a future enhancement to attachments in Swift Testing. Read on!
We introduced attachments to Swift Testing in Swift 6.2. This feature allows you to create a file containing data relevant to a test. In XCTest on Apple platforms, you can also specify the lifetime of an attachment by setting the lifetime property of an XCTAttachment object. This lets you avoid serializing and saving an attachment if its data won't be necessary (i.e. "if the test passes, don't bother saving this attachment.")
We didn't initially include this feature in Swift Testing so we could keep the scope of the feature narrow, but we're now looking at implementing it for an upcoming Swift release. So my question to the community is: if you could tell Swift Testing to only record an attachment to a test under certain conditions, what would those conditions be?
For example (these are not the only possible answers!):
- Always record this attachment
- Record this attachment only if the current test fails
- Record this attachment only if the current test passes
- etc.