In a unit test I have an expectation for notification which I provide to the method waitForExpectation: timeout:. The last one doesn't fail so the expectation is fulfilled. But the handler of the notification sometimes isn't being invoked. I know it because NSLog at the start of the handler isn't printed in this case.
XCTestExpectation *expectation = [self expectationForNotification:NotificationName
object:object
handler: ^BOOL(NSNotification *notification) {
NSLog(@"handler");
<...>
}];
[self waitForExpectations:@[expectation] timeout:timeout];
How is it possible that the expectation is fulfilled, but its handler hasn't been invoked?