似乎octest不会减少测试中创建的实例的引用计数
- (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上有一个[NSNotificationCenter默认中心]监听器。此vc实例上的侦听器将从其他测试中调用。
为什么???
答案 0 :(得分:1)
...您是从视图控制器中删除通知观察者吗?致addObserver:
的电话需要与相应的removeObserver:
匹配,否则您可能会遇到这类问题。