OCMock NSOperation

I am trying to write some Unit tests to test some of the custom NSOperationsones we are writing. What I would like to do is create a Mock from NSOperationand put it on NSOperationQueue, and then wait for it to complete. I know that I can use methods and not use OCMock at all , but I really don't want to do this. I would like to use OCMock. The code I'm trying to run looks something like this:

MYOperation *operation = [MYOperation new];
id mockOperation = [OCMockObject partialMockForObject:operation];
[NSOperationQueue *queue = [NSOperationQueue new];
[queue setMaxConcurrentOperationCount:1];
[queue addOperation:mockOperation];

When unit test goes to this line:

[queue addOperation:mockOperation];

I get an exception call of an excluded object. Anyone have any suggestions on how I can overcome this?

+5
source share
2 answers

ARC, operation, , , . , :

[queue addOperation:operation];

... - , .

+2

ARC mockOperation nil ( , ) Apple. . mockOperation addOperation:; .

0

All Articles