Lollypop
Lollypop

Reputation: 261

All tests did not finish - xcode 4.5

When i try to run the unit test for my projects, i get test succeeded. But in the log navigator i get warning saying 'All tests did not finish'. But the same code works fine in another machine and all tests succeeds without any warning. I searched for other posts related this and tried everything, but nothing works for me. And also all of a sudden some unit-tests fail without any reason, but succeeds when i run it again. I even tried resetting the simulator, nothing works.

Any suggestions?

Upvotes: 6

Views: 1418

Answers (2)

Lollypop
Lollypop

Reputation: 261

Looks like you get this warning if you are using OCMOCK and you try to mock 'self'. Once i changed this, it fixed my problem.

Upvotes: 0

AlwaysLearning
AlwaysLearning

Reputation: 8829

Try this... open a Terminal in your project's folder and type the following:

xcodebuild -list

If you have Unit Tests in your project you should see at least two targets: ProjectName and ProjectNameTests.

Now type the following command (note: you will need quotes around the ProjectNameTests if it has spaces):

xcodebuild -target ProjectNameTests build

You will almost certainly see something like the following towards the end of the output:

/Applications/Xcode.app/Contents/Developer/Tools/RunUnitTests:68: note: RunUnitTests exited without running tests because TEST_AFTER_BUILD was set to NO.

You can fix this in Xcode by selecting your project in the Project Navigator (Cmd-1), selecting your ProjectNameTests target, selecting Build Settings and scrolling down to the Unit Testing section. Change the Test After Build setting from No to Yes and type Cmd-U to run your Unit Tests again. This time it should work.

Hope this helps!

Upvotes: 5

Related Questions