Choosing specific test targets or test suites within `swift test`

I'm currently encountering a scenario where I want swift test to accept a specific test suite or test target such that only specific tests are run in different circumstances. For instance, we have plain unit tests for our libraries but we also have integration tests that hit the network to make sure that changes to the server-side don't break our client before deploying them. Running the library unit tests during the server-side check doesn't make sense, and running the integration tests during local development doesn't always make sense either (though we do want to make sure they still compile and run, so running them optionally would be nice).

Is it at all possible to do this in a single swift package, and if not is this something that's technically feasible to do on all the platforms swift supports?

You can use swift-test's --filter option to run a subset of tests. Run swift test --help to see details.

2 Likes

Ah thanks! Didn't notice that :slight_smile: