Description
Motivation
When running a test repeatedly, it is currently impossible for code inside the test to differentiate between different iterations within the same test run.
A concrete example where this poses an issue is with the SnapshotTesting library. It generates a unique name for each snapshot used in a test. E.g. when a test checks 3 snapshots it generates 3 unique names for those. When a test is ran multiple times it needs to "reset" these names between test iterations for this to work. However, it currently has no way to know the difference between 3 snapshots within a single test or 1 snapshot in a test that's ran 3 times repeated.
To solve this it needs to be able to detect that a test it has seen before is actually a different iteration. The issue is being tracked on there side here: pointfreeco/swift-snapshot-testing#963.
Proposed solution
A solution could be to add an iteration: UInt
property to Test
that gets incremented for each iteration. Something like this is actually already printed to the console in Xcode. SnapshotTesting could use that to "reset" the unique snapshot names when the iteration changes for the same test.
I feel like this somewhat relates to #671, where uniquely identifying parametrized cases are discussed. They are not entirely the same though.
Snapshot names should not be reset for different parametrized cases, only for different iterations when running repeatedly. Similarly, you probably want to be able to still identify a parametrized case across different iterations.
So while both problems and solutions are very similar, they do have different use cases and probably ask for separate fields.
Alternatives considered
No response
Additional information
No response