I am trying to set up a simple OCMock unit test in an iOS project, just to get familiar with the framework.
I have a mocking DataLoader class, and although I call this method myself, my wait fails:
- (void)testSimpleMocking {
However, when I run this test, I get an error message:
/Users/Craig/projects/MyApp/Unknown.m: -[MockingDataLoaderTest testSimpleMocking] : OCMockObject[DataLoader]: expected method was not invoked: dispatchLoadToAppDelegate:<OCMAnyConstraint: 0x1a3d890>
How is this possible when I call the method myself?
Edit: More complicated case:
- (void)testDataLoaderWaitsForDownload { id mock = [OCMockObject niceMockForClass:[DataLoader class]]; id metadataItem = [OCMockObject niceMockForClass:[NSMetadataItem class]];
And the implementation of the waitForDownload:thenLoad: method:
- (void)waitForDownload:(NSMetadataItem *)file thenLoad:(BOOL)load { NSURL *metadataItemURL = [file valueForAttribute:NSMetadataItemURLKey]; ...
Error with error:
Unknown.m:0: error: -[MockingDataLoaderTest testDataLoaderWaitsForDownload] : OCMockObject[NSMetadataItem]: expected method was not invoked: valueForAttribute:@"kMDItemURL"
source share