ios - Using OCMock on NSOperation gives bad access -


i writing unit test , giving me trouble. turns out can reproduce trouble using ocmock , normal obj-c. sharing simple test reproduces problem here in hope can me understand why failing , possibly how might write test without crashing.

the error message exc_bad_access(code=2,address=0x58)

-(void)testifnsoperationismockable {     nsoperationqueue *queue = [nsoperationqueue new];     queue.maxconcurrentoperationcount = 1;     [queue setsuspended:yes];      nsoperation *operation = [nsblockoperation blockoperationwithblock:^{         nslog(@"i simple operation.");     }];      id mockoperation = [ocmockobject partialmockforobject:operation];      [[mockoperation expect] cancel];      [queue addoperation:mockoperation]; // chrash happens on line      [queue cancelalloperations];      [queue setsuspended:no];      [mockoperation verify]; } 

i know might seem silly test, in real unit test queue wrapped in manager, operation custom implementation , cancel sent wrapper , targeting 1 specific operation, bear me , overly simple test.

as suggested in previous comment, can add original operation variable queue


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -