我正在尝试为OSX提供一个简单的OCMock测试,但似乎无法正确安装。我相信我已经遵循了说明,但是测试构建在链接步骤上失败了。
在fooTests.m中:
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
@interface fooTests : XCTestCase
@end
@implementation fooTests
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testOCMockPass {
id mock = [OCMockObject mockForClass:NSString.class];
[[[mock stub] andReturn:@"mocktest"] lowercaseString];
NSString *returnValue = [mock lowercaseString];
STAssertEqualObjects(@"mocktest", returnValue, @"Should have returned the expected string.");
}
@end但是,在构建过程中,我会收到以下警告/错误:
fooTests.m:56:5: Implicit declaration of function 'STAssertEqualObjects' is invalid in C99
Undefined symbols for architecture x86_64:
"_STAssertEqualObjects", referenced from:
-[fooTests testOCMockPass] in fooTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)在测试构建阶段,我获得了与XCTest和OCMock链接的“”。OCMock.framework位于基目录中,它也位于搜索框架和标题的路径中。有人能帮我告诉我我做错了什么吗?
看起来编译器似乎不知道STAssertEqualObjects()是什么(也就是说,我没有包含一些内容),因此它不知道该链接什么,因此出现了另外两个错误。我只是不知道我还需要包括什么。
发布于 2014-01-23 00:19:37
这不是OCMock问题。您正在使用XCUnit ( Xcode 5单元测试框架),但是您正在调用STAssertEqualObjects (来自OCUnit,Xcode 4单元测试框架)。只需将其更改为XCTAssertEqualObjects即可。
https://stackoverflow.com/questions/21296864
复制相似问题