`Executed 0 tests, with 0 failures (0 unexpected)` when running individual test cases in Xcode

1.1k views Asked by At

When I run tests in Xcode, as long as I run all the tests collectively they execute normally. However, if I run only one individual test class or one individual test function within a test class, it doesn't execute any tests at all and prints: Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds

Upon debugging I've found that it does execute individual tests if I choose a particular other scheme I have, but my other two schemes don't execute the individual tests. I also noticed that if I edit one of the two problematic schemes to use the same Build Configuration as the working scheme, the individual tests do work (each of my schemes uses a different build configuration).

How do I make the problematic build configurations work to let me execute individual tests?

1

There are 1 answers

0
wristbands On

I was able to figure it out!

If I click on my project in the Project navigator, then click on my project in the left sidebar of the page that appears, and then go to the Info tab, I can see at the bottom of the Configurations section it says:

"Use ConfigurationName for command-line builds"

If I click the dropdown and change it to a different build configuration, it makes the scheme that uses that build configuration able to execute individual tests! And, as one might expect, it also makes the scheme previously able to execute individual tests no longer able to.

It would be nice if I could dynamically change the build configuration for command-line builds based on which scheme is active in Xcode, but as of yet I have not figured out how to do so.

So for now, just know that you can manually change this build configuration value whenever you want to run individual tests for a scheme.