swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
708 stars 47 forks source link

Add a way to run a test multiple times in a row #832

Open ahoppen opened 1 month ago

ahoppen commented 1 month ago

Sometimes, when debugging a non-deterministic test, it is useful if you can run it multiple times in a row until it fails. It would be great if the Swift Extension offered that ability.

adam-fowler commented 1 month ago

Using swift-testing you could do that.

@Test(arguments: 0..<100)
func testMultiple(attempt: Int){
    ...
}
ahoppen commented 1 month ago

I was thinking XCTest ;-)

adam-fowler commented 1 month ago

This seems quite niche. Is there any reason you can't wrap the test in a for loop that runs it multiple times.

ahoppen commented 1 month ago

I could. I just found the Xcode feature to run a test repeatedly useful quite regularly because it also gives you a few things out of the box like logging which iteration it’s currently on.

plemarquand commented 1 month ago

I've used this a few times in Xcode to diagnose flakey XCTests that have setUp/tearDown

adam-fowler commented 4 weeks ago

I didn't know this was an option in Xcode.