Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode no longer recognizes tests

I've been troubleshooting this for a few days and am all out of ideas.

I was using unit testing in Xcode and it was working great. All of a sudden Xcode no longer recognizes my tests. If I go to the tests panel, it shows that I have zero tests. I actually have 13.

The ability to run individual tests or certain classes is now gone. It doesn't show the buttons in the gutter of the editor area.

I am still able to run all of my tests if I click the button to the right of the "0 Tests" in the test panel. When I click this it then starts populating all of my tests and they still appear to run properly. However, now that the tests are shown in the tests panel, they still are not linked to my tests in the classes. Usually if you click on a test, it will take you to it in the file where it lives. This functionality is gone.

I opened up another old project I had saved and it is having the same issue. However, I started a new project and it is working just fine and is showing no signs of any problems.

Any ideas as to what I may have done? I've found a few other threads out there about this on here, but none of them have gotten any helpful responses and are at least a number of months old. Hoping maybe creating a new thread will bump this again.

My next thought is to start the project over again and copy my files over. Not sure what else to do.

like image 836
Mathieson Avatar asked Dec 10 '14 05:12

Mathieson


2 Answers

I had the same problem, and all my methods have the test prefix.

So, the problem seems to be with Xcode indexing, as some targets could see all tests and some could not. To create a fresh index follow these steps:

  1. Quit Xcode
  2. Go to ~/Library/Developer/Xcode/DerivedData/
  3. Remove this folder. You can use rm -rf YourProjectDir

Done! When you open the project wait for reindexing and the tests should appear as usual.

like image 123
mcatach Avatar answered Sep 21 '22 11:09

mcatach


All test method begin with "test":

func testValidateStudent()
{
    // your code
}

make sure that your test methods begin with "test".

like image 45
Ahsan Avatar answered Sep 21 '22 11:09

Ahsan