ST-0024: Per-test-case repetitions

Hello Swift Community!

The review of ST-0024 “Per-test-case repetitions” begins now and runs through Monday April 20, 2026. The proposal is available here:

swift-evolution/proposals/testing/0024-per-test-case-repetitions.md at main · swiftlang/swift-evolution · GitHub

Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager. When messaging the review manager directly, please keep the proposal link at the top of the message.

What goes into a review?

The goal of the review process is to improve the proposal under review
through constructive criticism and, eventually, determine the direction of
Swift. When writing your review, here are some questions you might want to
answer in your review:

  • What is your evaluation of the proposal?
  • Is the problem being addressed significant enough to warrant a change to Swift?
  • Does this proposal fit well with the feel and direction of Swift?
  • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
  • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

More information about the Swift evolution process is available at

swift-evolution/process.md at main · swiftlang/swift-evolution · GitHub

Thank you for contributing to Swift!

Brian Croom
Review Manager

8 Likes

This feels like it's getting into "that proposal review could have been a pull request" territory, because the proposed behavior is obviously how it should work. But I get since it impacts user-facing behavior, yada yada yada...

Ship it. :ship:

8 Likes

We did have that discussion! But yes, it does change how tests run, so the TWG deemed a formal proposal necessary.

Ship it!

2 Likes

Seems like a bug the previous way it worked. Much improved with the new behaviour. +1

2 Likes

Agreed; ship it.

2 Likes

Excellent!

2 Likes

Thanks for the feedback so far, folks! As a small update, @harlanhaskins has prepared a branch so I can now share instructions for:

Trying it out!

To try this feature out in a Swift package, add a dependency to the harlan/try-per-test-case-repetitions branch of swift-testing to your package:

...
dependencies: [
  ...
  .package(
    url: "https://github.com/swiftlang/swift-testing.git",
    branch: "harlan/try-per-test-case-repetitions"
  ),
]

Then, add a target dependency to your test target:

.testTarget(
  ...
  dependencies: [
    ...
    .product(name: "Testing", package: "swift-testing"),
  ]
)

Finally, run your tests as usual with swift test:

% swift test
...
◇ Test run started.
↳ Testing Library Version: 6.4-dev (ec33e00)
◇ Test failsAlways() started.
◇ Test succeedsAlways() started.
✔ Test succeedsAlways() passed after 0.001 seconds.
✘ Test failsAlways() recorded an issue at PackageTestExampleTests.swift:5:5: Expectation failed: 1 == 2
↳ 1 == 2 → false
◇ Test failsAlways() started (repetition 2).
✘ Test failsAlways() recorded an issue at PackageTestExampleTests.swift:5:5: Expectation failed: 1 == 2
↳ 1 == 2 → false
◇ Test failsAlways() started (repetition 3).
✘ Test failsAlways() recorded an issue at PackageTestExampleTests.swift:5:5: Expectation failed: 1 == 2
↳ 1 == 2 → false
✘ Test failsAlways() failed after 0.001 seconds with 1 issue.
✘ Test run with 2 tests in 0 suites failed after 0.001 seconds with 1 issue.
1 Like

Note that on this branch, all SwiftPM tests are opted in to repetition on failure, with a maximum retry count of 3 (because SwiftPM currently does not pass --repetitions to Swift Testing)

So, does this proposal include adding those options to SwiftPM or are they a future direction? Because it sounds like to use this feature effectively they need to be formally added, but the text of the proposal is a bit handwavey (he says with great respect, of course!)

This proposal does not explicitly add the flags to SwiftPM, but we really should add them as a follow up.

EDIT: I posted a PR here to SwiftPM to add these (and will update this proposal to add them). Add `swift test` command line flags for test repetition by harlanhaskins · Pull Request #9944 · swiftlang/swift-package-manager · GitHub

1 Like

Hi all, I've posted a PR to update the proposal to add the swift test flags and expose the feature more broadly. Thanks!

We should make sure the documentation for these flags is clear re: XCTest support. I know Xcode test plans have analogous functionality, but I don't think it's available from the command-line interfaces SwiftPM wraps, and I don't think it's implemented in corelibs-xctest.

1 Like

Hi folks, this is now returned for revision to incorporate the SwiftPM flags discussed during the review.

2 Likes