4

I recently removed some old test classes from my project and deleted the files. As expected, the files were moved to the trash and showed up as removed in git.

Unfortunately, the test classes and the test cases they define continue to appear in the test navigator. I've tried the usual suspects like cleaning & rebuilding, and quitting & reopening Xcode.

The remaining tests run just fine; at the end of an all-tests run, the navigator shows the phantom tests with no indicated status.

Un-run phantom test cases

I've begun to think that there is some erroneous state in the project file that's keeping these phantom test cases around, but I don't know enough about the internals to debug further.

My problem is distinct from the scenario described here because all of my test cases stick around in test navigator, rather than all disappearing.

Community
  • 1
  • 1
aednichols
  • 2,292
  • 2
  • 19
  • 28

2 Answers2

5

Delete the DerivedData directory. Apparently Xcode parses the test classes and writes test definition files of some sort to DerivedData. It then uses those definition files to populate the test navigator.

Unfortunately, deleting a test class from within Xcode does not cause that cache to be invalidated and rebuilt. Instead, one must clear the cache manually.

I had incorrectly assumed that the test definitions are stored in memory, which is why I expected quitting Xcode would solve the problem.

aednichols
  • 2,292
  • 2
  • 19
  • 28
1

I found I had to do the following steps in order, otherwise the deleted tests reappear:

  1. Close the project (but don't quit Xcode).
  2. Window > Projects > select the project.
  3. Click the "Delete" button next to "Derived Data".
  4. Quit Xcode and restart.
  5. Wait for Xcode to finish indexing.
  6. Run the tests.
Will Hains
  • 996
  • 1
  • 12
  • 21