2011-06-18 28 views
5

我试图运行一个GHUnit测试来测试一个setter实际上适用于我的应用程序中的NSManagedObject对象。我的应用程序被称为机器,我的GHUnit目标被称为测试。我已将Machine作为依赖项添加到Tests目标。我在测试中的对象叫做Goal。下面是代码和链接中的错误。GHUnit链接器错误与应用程序类

#import <GHUnitIOS/GHUnit.h> 
#import <CoreData/CoreData.h> 
#import "Goal.h" 
#import "GoalRec.h" 

@interface ControllerTests : GHTestCase { } 
@property (retain) Goal *goal; 
@end 

@implementation ControllerTests 
@synthesize goal; 

- (BOOL)shouldRunOnMainThread { 
// By default NO, but if you have a UI test or test dependent on running on the main thread return YES 
return NO; 
} 

- (void)setUpClass { 
    // Run at start of all tests in the class 
} 

- (void)tearDownClass { 
    // Run at end of all tests in the class 
} 

- (void)setUp { 
    // Run before each test method 
    self.goal = [[[Goal alloc] init] autorelease]; 
} 

- (void)tearDown { 
    // Run after each test method 
    self.goal = nil; // prevents memory leak 
} 

- (void)testImageArray { 

    NSString *str = @"Hello"; 
    Goal *obj = self.goal; 
    obj.goal = str; 
    GHAssertEqualStrings(obj.goal, @"Hello", nil); 

} 

@end

Ld的/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator/Tests.app/Tests正常I386 CD /用户/ dlwhitehurst /开发/编码/ Objective-C/iPad /机器 setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH“/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/ bin:/ usr/sbin:/ sbin“ /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot/Developer/Platforms/iPhoneSimulato r.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine -cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator -F/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator -F/Users/dlwhitehurst/Development/Frameworks -filelist/Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Intermediates/Machine。 build/Debug-iphonesimulator/Tests.build/Objects-normal/i386/Tests.LinkFileList -mmacosx-version-min = 10.6 -ObjC -all_load -Xlinker -objc_abi_version -Xlinker 2 -framework CoreData -framework GHUnitIOS -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/dlwhitehurst/Library/Developer/Xcode/DerivedData/Machine-cscchzscengbcmcmeyzxlkbhumdn/Build/Products/Debug-iphonesimulator/Tests.app/Tests

个为i386硬件架构未定义的符号: “_OBJC_CLASS _ $ _目标”,从引用: objc级,裁判在ControllerTests.o LD:符号(S)没有找到i386硬件架构 collect2:LD返回1个退出状态

回答

0

更好的解决方案可能是重复目标,同时为GHUnit测试创建一个目标,而不是创建新目标。