全て:
次の単体テスト クラスがあります (実装ファイルを示します)。
@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
テストを実行すると、トークンが nil であるため testB は失敗しますが、問題はありませんが、なぜtoken
破棄されるのでしょうか?