9

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?

Robert Höglund
  • 10,010
  • 13
  • 53
  • 70
deanWombourne
  • 38,189
  • 13
  • 98
  • 110
  • 3
    Not really an answer, 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. It's pretty too. Just my $0.02. – d11wtq Dec 08 '10 at 14:13
  • Hmmm, I was hoping none of the answers said just to use something else, I've only just got SenTestingKit working! Oh well, live and learn. – deanWombourne Dec 08 '10 at 14:43
  • is it appropriate to ask Xcode 4 questions yet? – John Smith Dec 08 '10 at 15:07
  • I'm pretty sure a non-disclosure doesn't forbid asking questions. It might, however, forbid anyone from answering them ;) – deanWombourne Dec 08 '10 at 15:13
  • You can go to the Apple dev forums to ask XCode 4 questions for now, when it's out of beta we'll be able to talk about it here. – Kendall Helmstetter Gelner Dec 08 '10 at 17:03
  • If I had tried to run unit tests in Xcode 4 I would have run in to much the same problem my self. – Robert Höglund Dec 08 '10 at 20:44
  • 2
    @d11wtq - if you put your comment as an answer I can mark it as accepted - GHUnit works, SenTestingKit doesn't. – deanWombourne Dec 08 '10 at 21:42
  • Done, thanks :) Glad it helped. I just default to throwing GHUnit in all my projects now, and all my work mates do the same. – d11wtq Dec 08 '10 at 22:32
  • I've added it to the generic set of shared libraries that my company uses as well :) – deanWombourne Dec 09 '10 at 12:03

2 Answers2

11

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.

makdad
  • 6,402
  • 3
  • 31
  • 56
5

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

d11wtq
  • 34,788
  • 19
  • 120
  • 195
  • 2
    I am trying to figure out why @d11wtq think GHUnit is better than SenTestingKit, after all SenTestingKit is integrated into xcode4,that will be great!http://stackoverflow.com/questions/5348712/why-gh-unit-is-better-than-sentestcase-in-xcode4 – Forrest Mar 18 '11 at 07:40
  • Um how about a document that explain how to actually write and run unit tests in Xcode 4? – TheLearner Mar 22 '11 at 10:21
  • BTW GHUnit is also a nightmare - the installation instructions make no sense at all e.g.: In the Finder, copy GHUnit.framework to your project directory (maybe in MyProject/Frameworks/.) - what does that even mean!? – TheLearner Mar 22 '11 at 10:22
  • Try http://stackoverflow.com/questions/1675307/best-way-to-install-a-custom-cocoa-framework – occulus Mar 22 '11 at 11:19
  • @TheLearner That instruction just means copy the .framework somewhere into your project, e.g. a new folder in your project for frameworks called "Framework". – occulus Mar 22 '11 at 11:23
  • @TheLearner - you're right about the install instructions. That's why I wrote this: http://longweekendmobile.com/2011/02/23/tdd-best-practices-testing-in-ios4-with-ghunit-part-1/ – makdad Apr 12 '11 at 00:25
  • I'm fairly new (1 month) to Objective-C development (but not programming) and Xcode 4. I tried GHUnit at first, and it was ok, but after reading the post by @makdad below, I found that Xcode 4's built-in unit testing stuff works great for me. Apparently they have improved this a lot since Xcode 3.x. So it might be worth a look too. – jpswain Aug 11 '11 at 19:31