【发布时间】:2011-03-28 21:05:11
【问题描述】:
我在 XCode 4 中使用单元测试创建了一个新的 Cocoa Touch 静态库项目并添加了一个类别:
// NSString+Inflections.h
@interface NSString (Inflections)
- (NSString *)pluralize;
@end
// NSString+Inflections.m
@implementation NSString (Inflections)
- (NSString *)pluralize { return self; }
@end
然后将适当的导入语句添加到我的测试用例中并编写以下测试:
- (void)testPluralize
{
NSString *test = @"person";
NSString *expected = @"people";
NSString *actual = [test pluralize];
STAssertEqualObjects(actual, expected, @"Whoops");
}
但是,这会导致我的测试因“无法识别的选择器发送到实例”而崩溃(未失败)。
如何测试库中的类别?
如果我的描述不充分,我已经压缩并上传了完整的项目here。
【问题讨论】:
标签: iphone objective-c cocoa-touch xcode testing