在 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
当我在 Xcode 的模拟器中使用 Build and Run 时,它运行良好。但是,当我在终端中运行以下命令时:
GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug -sdk iphonesimulator4.0 build
我得到这个输出:
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 **
这个“Trace/BPT Trap”的事情也发生在 OCUnit 上,我希望 GHUnit 能解决它,但它不在命令行上。有人知道它是关于什么的吗?这似乎与在您不应该使用的上下文中使用 UIKit 有关,但我不明白限制到底是什么。