I have the following minimal test case in a minimal project created following the GHUnit README:
#import <GHUnitIOS/GHUnitIOS.h>
#import <UIKit/UIKit.h>
@interface MyTest : GHTestCase { }
@end
@implementation MyTest
- (BOOL)shouldRunOnMainThread {
return YES;
}
- (void)testFoo {
UITableViewCell *cell =
[[UITableViewCell alloc] initWithStyle:UITableViewStylePlain
reuseIdentifier:@"foo"];
NSLog(@"cell: %@", cell);
NSLog(@"cell.textLabel: %@", cell.textLabel);
}
@end
It runs fine when I use Build and Run in the simulator in Xcode. However, when I run the following command in the terminal:
GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug -sdk iphonesimulator4.0 build
I get this output:
Running: /Users/<user>/Desktop/tmp/TestApp/build/Debug-iphonesimulator/Tests.app/Tests -RegisterForSystemEvents
Tests(39346) malloc: protecting edges
Tests(39346) malloc: recording malloc stacks to disk using standard recorder
Tests(39346) malloc: enabling scribbling to detect mods to free blocks
Tests(39346) malloc: process 39249 no longer exists, stack logs deleted from /tmp/stack-logs.39249.Tests.ac1JfL.index
Tests(39346) malloc: stack logs being written into /tmp/stack-logs.39346.Tests.t8LG4p.index
Test Suite 'Tests' started.
MyTest/testFoo 2010-09-06 23:24:25.006 Tests[39346:903] cell: <UITableViewCell: 0x5a6d190; frame = (0 0; 320 44); layer = <CALayer: 0x5a6d390>>
RunTests.sh: line 28: 39346 Trace/BPT trap $RUN_CMD
Command /bin/sh failed with exit code 133
Command /bin/sh failed with exit code 133
** BUILD FAILED **
This "Trace/BPT Trap" thing happens with OCUnit too, and I was hoping GHUnit would solve it, but it doesn't on the command line. Anybody have any idea what it's about? It seems to have to do with using UIKit from a context you're not supposed to, but I don't understand what exactly the restriction is.