Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCTest did not finish in Xcode 5

Tags:

xcode5

xctest

I have one test class and one test case. When I run my unit test, Xcode tells me all of my tests passed, but I have a warning that my tests didn't finish.

Do I have to do something special with XCTest to let it know I'm done with a particular test case?

Update: It may be a timing issue/bug. I put an [NSThread sleepForTimeInterval:.1]; in the tearDown method and now it works every time. Xcode also finished the tests fine periodically on its own without the sleep.

Update 2: Looks like some odd Xcode bug, I added a third test that is just doing text formatting validation and the warning shows up again.

Test Failure Image

like image 707
Collin Avatar asked Sep 24 '13 20:09

Collin


1 Answers

I never got the warning you mention, but after converting to Xcode 5 XCTest (with refactoring menu and swapping the framework myself) my tests ran forever (for some value of forever...) but never actually began executing (setUp and test methods not called at all).

I changed my Test target's, Build Settings > Packaging > Wrapper Extension from "octest" to "xctest" and the problem was immediately resolved.

Wrapper Extension setting existing and new value

To answer your question, a test should finish as soon as its execution finishes and its tearDown method completes. A test with no code will pass successfully. Try setting a breakpoint or log message inside your test to verify it is actually being called and make sure your tearDown is not hanging for any reason.

like image 103
owenfi Avatar answered Oct 16 '22 05:10

owenfi