【发布时间】:2013-10-30 10:03:44
【问题描述】:
我正在阅读 Graham Lee 的“Test-Driven iOS Development”来学习 OCUnit。我认为它比 Xcode 落后了几个版本,但仍然是一个有用的资源。
在本书中,测试对象在类扩展中声明,如下所示:
@interface BROAnswerTests : XCTestCase {
BROAnswer *answer;
BROAnswer *otherAnswer;
}
@end
然后在- (void)setUp中实例化:
- (void)setUp
{
[super setUp];
answer = [[BROAnswer alloc] init];
answer.text = @"The answer is 42";
answer.person = [[BROPerson alloc] initWithName:@"Graham Lee" avatarLocation:
@"http://example.com/avatar.png"];
answer.score = 42;
}
在类扩展中使用@property 是否安全?
【问题讨论】:
标签: objective-c unit-testing properties ocunit