我有一个简单的经理对象,并且在猕猴桃中使用模拟,我想在我调用[aPOIManager fetchNear:location]
时检查它是否在其下载程序上调用downloadPOIsNear:completionBlock:
。
一切正常,直到我决定在大型中央调度中将调用发送到下载器。
调用是异步的,测试现在失败了。 Kiwi具有异步检查某些值的功能,但不检查异步调用。
以下是我测试的一部分:
it(@"should call the proximity downloader", ^{
CLLocation *location = [[CLLocation alloc] initWithLatitude:1.0f longitude:1.0f];
id<RMProximityDownloader> mockDownloader =
[KWMock mockForProtocol:@protocol(RMProximityDownloader)];
[[(NSObject*)mockDownloader should] receive:@selector(downloadPOIsNear:completionBlock:)];
RMPOIManager *aPOIManager = [[RMPOIManager alloc] initWithDownloader:mockDownloader];
[aPOIManager fetchNear:location];
});
答案 0 :(得分:1)
试试这个:
[[(NSObject*)mockDownloader shouldEventually] receive:@selector(downloadPOIsNear:completionBlock:)];
如果需要,您还可以使用shouldEventuallyBeforeTimingOutAfter(seconds)
。