我創建了一個視圖控制器viewsampleViewController ..它有兩個方法setname和getname ..我爲該視圖控制器創建一個測試用例。我的測試用例名稱是newTestCase,方法名稱是testName。
#import "newTestCase.h"
#import "viewsampleViewController.h"
@implementation newTestCase
在我的測試名法
,
-(void)testName{
NSString *[email protected]"hello";
v =[[viewsampleViewController alloc] init];
STAssertNotNil(v,@"v doesnt created");
[v setuname:@"hello"];
NSString *a=[v getuname];
STAssertEquals(b,a,@"error:name not equal");
[v release];
}
-(void)setUp{
v=[viewsampleViewController alloc];
}
-(void) tearDown{
[v release];
}
當我建立我得到一個錯誤
Ld "build/Debug-iphoneos/Unit test.octest/Unit test" normal armv6
cd /Users/anande/Documents/viewsample
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -bundle -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/anande/Documents/viewsample/build/Debug-iphoneos -F/Users/anande/Documents/viewsample/build/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/Developer/Library/Frameworks -filelist "/Users/anande/Documents/viewsample/build/viewsample.build/Debug-iphoneos/Unit test.build/Objects-normal/armv6/Unit test.LinkFileList" -dead_strip -framework Foundation -framework SenTestingKit -miphoneos-version-min=3.1.3 -o "/Users/anande/Documents/viewsample/build/Debug-iphoneos/Unit test.octest/Unit test"
Undefined symbols:
"_OBJC_CLASS_$_viewsampleViewController", referenced from:
[email protected] in newTestCase.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
plz幫助我,
我的解決辦法是在鏈路上嘗試,如果你想.. :) 鏈接:http://stackoverflow.com/a/10415850/1092219 – 2012-05-02 14:34:26