I'm running into this issue where random asynchronous test cases will timeout instantly if another test attempts to access a torn down singleton while tearing down.
MySingelton :
__strong MySingelton *sharedInstance = nil;
+ (MySingelton *)sharedInstance {
return sharedInstance;
}
+ (void)setSharedInstance:(MySingleton *)sharedSingelton {
sharedInstance = sharedSingleton;
}
Test 1:
- (void)setUp {
[super setUp];
[MySingleton setShareInstance:[[MySingelton alloc] init]];
}
- (void)tearDown {
[MySingleton setSharedInstance:nil];
NSLog(@"%@", [MySingleton sharedInstance]);
}
Test 2:
- (void)testAsync {
[self prepare];
[self performSelector:@selector(_confirmAsync) withObject:nil afterDelay:0.1];
[self waitForStatus:kGHUnitWaitStatusSuccess timeout:1];
}
- (void)_confirmAsync {
[self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testAsync)];
}
In this example, the waitForStatus:timeout: in Test 2 will timeout instantly without ever making the call to _confirmAsync. Any ideas? Thanks!