Iphone OCUnit中无法识别导入的文件
我正在使用XCode 3.2.3和iOS 4.0上的OCUnit对我的iPhone应用程序进行单元测试。我已经成功地设置了我的测试环境,以适当地通过和失败基本测试,但当我导入自己的文件(在本例中为“UserAccount.h”)时,它无法编译并告诉我: “\u OBJC\u CLASS\u$\u UserAccount”,引用自: 然后它会说“找不到符号”。这让我觉得是某种链接器错误,但我不知道发生了什么。我已经构建并清理了无数次所有目标,但都无济于事。以下是我的测试代码:Iphone OCUnit中无法识别导入的文件,iphone,unit-testing,xcode,linker,ocunit,Iphone,Unit Testing,Xcode,Linker,Ocunit,我正在使用XCode 3.2.3和iOS 4.0上的OCUnit对我的iPhone应用程序进行单元测试。我已经成功地设置了我的测试环境,以适当地通过和失败基本测试,但当我导入自己的文件(在本例中为“UserAccount.h”)时,它无法编译并告诉我: “\u OBJC\u CLASS\u$\u UserAccount”,引用自: 然后它会说“找不到符号”。这让我觉得是某种链接器错误,但我不知道发生了什么。我已经构建并清理了无数次所有目标,但都无济于事。以下是我的测试代码: #import "S
#import "SomeTestCase.h"
#import "UserAccount.h"
@implementation SomeTestCase
- (void)testUserAccount
{
// UserAccount.m //
UserAccount *testAccount = [[UserAccount alloc] initWithUsername:@"" password:@"" deviceToken:@""];
[testAccount registerNew];
NSLog(@"USERID = %@", testAccount.userID);
STAssertEquals([testAccount login], NO, @"Failure: Login should fail with blank username and password."); // should fail with no username or password
UserAccount *testAccount2 = [[UserAccount alloc] initWithUsername:@"user" password:@"" deviceToken:@""];
STAssertEquals([testAccount2 login], NO, @"Failure: Login should fail with blank password.");// should fail with no password
UserAccount *testAccount3 = [[UserAccount alloc] initWithUsername:@"" password:@"pass" deviceToken:@""];
STAssertEquals([testAccount3 login], NO, @"Failure: Login should fail with blank username.");// should fail with no password
}
@end
如有任何建议,将不胜感激。
谢谢
-Matt我猜UserAccount.m没有添加到测试目标中。这将导致“Symbols not found”(未找到符号)错误。我曾见过多个目标中Xcode识别头,即使实现文件不是目标的一部分
如果这不起作用,请尝试在Xcode 4中使用
Xcode>空缓存清空Xcode缓存…
至少您不应该在测试目标中包含应用程序.m文件。正确的方法是: