全部:
我有以下单元测试类(显示的实现文件):
@implementation SampleTests {
A* c;
NSString* token;
}
- (void)setUp
{
[super setUp];
// Set-up code here.
c = [[A alloc] init];
}
- (void)tearDown
{
// Tear-down code here.
[super tearDown];
}
- (void)testA
{
token = @"sample";
}
-(void)testB
{
[c method:token]; // <-- fails because token is nil, but c has a correct value. Why!
}
@end
当我运行测试时,testB 失败,因为 token 为 nil,但是 c 没问题,那为什么它token
被破坏了?