We are currently using XCTAttachment
for snapshot testing and add several images to an XCTIssue
. As far as I can tell, currently Comment
only support strings or did I miss something?
grynspan
(Jonathan Grynspan)
January 20, 2025, 12:58pm
2
Correct—Comment
is more or less just a human-readable string.
Attachments are currently experimental SPI:
opened 01:54PM - 19 Sep 24 UTC
closed 01:05AM - 03 Nov 24 UTC
enhancement
public-api
attachments/activities
### Description
The XCTest framework has an attachment feature, which is bene… ficial for snapshot tests to visualize the differences. It would be advantageous if this feature were incorporated into SwiftTesting as well.
swiftlang:main
← swiftlang:jgrynspan/attachments
opened 05:24PM - 02 Nov 24 UTC
This PR introduces a new experimental feature, attachments. With this feature, y… ou can "attach" values that conform to a new `Test.Attachable` protocol to a test. With the right command-line incantation (TBD), Swift Testing will automatically write attachments to disk for you.
> [!NOTE]
> This PR does not teach Xcode or VS Code how to handle attachments produced by
> Swift Testing, nor does it add the necessary command-line arguments to the
> `swift test` command-line tool.
This PR is one of a series that I'll be posting to build out this feature.
As always, keep in mind that symbols marked `@_spi(Experimental)` are subject to change or removal without notice.
Resolves #714.
Resolves rdar://88648735.
### Checklist:
- [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should be updated.
Due to attachments' relatively large Swift interface, we are waiting for the Testing Workgroup to be fully set up before we propose it as API.
1 Like
Thanks. Can I already test it within Xcode?