4

This question is similar to: XCode run all the tests (even the disabled ones)

But different in that I'm not disabling any tests. I'm just pressing the single test icon next to a test function or test case:

Xcode 6.3.2 runs all the tests instead of just the one I selected KIF

A friend of mine is running KIF in a Swift project just like I am and has no problem with this. I'm guessing it's something to do with my setup:

I have a main xcworkspace file that contains my main target, a unit tests target, and an automated tests target (which contains the KIF tests). The workspace also has the pods project, using frameworks. That's it. Here's my scheme setup:

Scheme config 1

Scheme config 2

I've experienced this issue in all released versions of Xcode 6.

Edit

I found a workaround for the time being.

You have to modify each of your test classes (white space changes are fine). This will trigger Xcode to index those files and to recognize the tests and test cases and generate symbols & icons for them in the test navigator. (It's recommended to delete derived data first to remove any "ghost tests".)

If you don't do this for each test case class, all the unrecognized test case classes will always run, even if you only select one test to run.

Once you force Xcode to recognize all the test classes, you can successfully run a single test. (or a single test case, if you choose that instead.)

I also noticed while trying to fix this issue that the symbols and indexing for the default UnitTests target works fine. So there's something wrong with either a) having a second test target or b) my second test target meta info is corrupt or c) I set my second test target up incorrectly.

Community
  • 1
  • 1
Albert Bori
  • 9,832
  • 10
  • 51
  • 78
  • I was able to get around this by going to each file and saving (cmd+S) for every Xcode session. This issue has been fixed in Xcode 7 – Albert Bori Sep 24 '15 at 22:46

1 Answers1

-2

The test icon next to the class is not for a single test.

Unlike the method test icon (which only tests itself), the class test icon runs all the tests in the test class.

Delete your project's Derived Data. You can do this by closing the project, opening Window->Projects, then selecting your project. Click the Delete button to the right of the Derived Data path.

  • I'm aware of that. When I press the icon next to a specific test class, it runs all test classes (`KIFTestCase`) found in that entire test target. That behavior is not correct, expected, nor desired. When I press the icon next to a single test, it does the same. All tests. All test cases. – Albert Bori May 30 '15 at 00:28
  • Thanks for clarifying what's happening. You're right, that's not correct. Close Xcode, then delete the project's Derived Data. –  May 30 '15 at 00:34
  • While this does remove all the old test meta info, it does not fix the problem. :( – Albert Bori Jun 04 '15 at 22:20
  • Just to confirm, you deleted the Derived Data for each of the projects in the workspace? If so, I'm at a loss as to why it is running every test. You may have to offer a bounty on your question, to draw more attention to it. –  Jun 04 '15 at 22:26
  • I deleted `/Users/me/Library/Developer/Xcode/DerivedData/` which is where the `Derived Data` setting is pointed to in my Preferences. I've settled for a work around for the time being. See my updated question. – Albert Bori Jun 04 '15 at 22:31