Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing in XCode 4

I've managed to set up unit tests for my library in Xcode 4. I've performed builds with tests that I know will pass and fail (i.e. STAssertTrue(YES) and STAssertTrue(NO) ) just to make sure it's working. I'm using the default apple SenTest libraries following this document.

However, when my tests are running I'm getting this error in the build log :

An internal error occurred when handling command output: -[IDEActivityLogSectionRecorder endMarker]: unrecognized selector sent to instance 0x20310b580

To be clear, it's not affecting the running of the tests at all, just the output into the build window. All the tests run each time so I can tell a pass / fail by looking to see if the build succeeds or fails.

However, when my tests fail I can't find out which one fails because the output seems to stop when it gets to that error.

Does anyone have experience with unit testing / Xcode 4 / this error?

like image 544
deanWombourne Avatar asked Dec 08 '10 14:12

deanWombourne


People also ask

How do I run unit tests in Xcode?

⌘U will build and run all your test cases. It is the most commonly used shortcut when creating unit test cases. It is equivalent to ⌘R (build & run) while doing app development. You can use this shortcut to build your test target and run all the test cases in your test target.

How do you write unit test cases in Swift 4?

To create new unit case in iOS, go to File -> New -> File, and then select Unit Test Case Class. Doing so creates a template just like the one you got with your project. In our case, we want to name the file to correspond with the new Pokemon-related data structures we have introduced.

How do you write unit tests in Swift?

Click on the Test Navigator tab in the Xcode Navigator (the left-most window). This tab can also be reached by pressing ⌘ + 6. In the bottom left corner you can add the test target by pressing the '+' button. Follow the instructions on the screen and voila: You are now ready to write your first unit test.


2 Answers

I just posted this on another thread, but I'm going the opposite direction for Xcode 4.

Please see my blog post exploring the topic, leave a comment if you think I'm wrong.

like image 169
makdad Avatar answered Sep 21 '22 13:09

makdad


I realise it doesn't directly answer your question, but forget SenTestingKit and use GHUnit. It'll take you about 10 minutes to figure out (much more straightforward than OCUnit) and will save you a lot of headaches. IMHO, Apple should be shipping it with Xcode instead of OCUnit.

GHUnit can run your tests in a true application environment (with a GUI), or on the command line. It literally just drops into your existing project as a separate target.

https://github.com/gabriel/gh-unit

like image 38
d11wtq Avatar answered Sep 18 '22 13:09

d11wtq