apple/swift-testing

How do you filter for a test that includes parameters?

Closed this issue · 2 comments

Description

If I have two tests with the same function name but one of which takes a list of parameters, there doesn't appear to be a way to filter the tests to only run one of the tests eg If I have the following two tests

@Test(arguments: [1,2])
func testThis(value: Int) {
    #expect(value < 2)
}

@Test
func testThis() {
    #expect(1 < 2)
}

There doesn't appear to be a way to differentiate between the two tests

Expected behavior

  • swift test --filter testThis(value:) runs the first test
  • swift test --filter testThis() runs the second test

Actual behavior

  • swift test --filter testThis(value:) doesn't run either of the tests
  • swift test --filter testThis() runs both tests

Steps to reproduce

No response

swift-testing version/commit hash

25d0eed

Swift & OS version (output of swift --version ; uname -a)

No response

The --filter argument is a regular expression. You will need to escape the string you pass to it. In the example cases, I think you just want testThis\(value\:\) and testThis\(\).

Verified as working, interestingly I found you should really escape the "." and "/" when you have the full test name