Closed nicoabie closed 4 years ago
Hmm. Rather than diagnose the problem… I recommend not mocking NotificationCenter. Instead, just use it, and register the test suite as an observer to capture what is sent. I think you'll find the resulting test is easier to read.
Since NotificationCenter lives on outside the test run, you just have to make sure to remove the observer in tearDown
.
This seems related to #123
I would like to test the following code:
for that I have the following test :
This test fails because
addObserverForName
gets called twice.If I jump into
blockHandler(noteMock);
I see one call pointing at the line which contains the call toaddObserverForName
with a null callback and on the next call it correctly points to the correct linecallback([note.userInfo valueForKey:@"tripId"], [note.userInfo valueForKey:@"data"]);
with the correct callback (different than null).Relevant PODS: