2011-06-18 55 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測試創建一個目標,而不是創建新目標。