0

It seems octest doesn't decrement reference count for instances created within a test

- (void)test_That_TaskFetcher_is_Invoked_from_tasksDownloaded {
    InboxViewController *vc = [[InboxViewController alloc] init];
    id fetcher = [OCMockObject mockForClass:[TaskFetcher class]];
    [vc setTaskFetcher:fetcher];
    [[fetcher expect] fetchTasksfromManagedObjectContext:OCMOCK_ANY
                                           withPredicate:OCMOCK_ANY
                                    WithBlockForEachTask:OCMOCK_ANY
                                        WithFailureBlock:OCMOCK_ANY
                                      WithNoResultsBlock:OCMOCK_ANY
                                     WithCompletionBlock:OCMOCK_ANY];
    [vc tasksDownloaded];
    STVerify(fetcher);
}

vc has a [NSNotificationCenter defaultcenter] listener on it. The listener on this vc instance is getting invoked from other tests.

why???

Zayin Krige
  • 3,229
  • 1
  • 35
  • 34

1 Answers1

1

...are you removing the notification observer from your view controller? Calls to addObserver: need to be matched with a corresponding removeObserver:, otherwise you can run into these sorts of issues.

lxt
  • 31,146
  • 5
  • 78
  • 83