jeudi 4 juin 2015

Is there a way to change one of parameters in OCMock and continue running the stubbed function

Hello I'm trying to change the parameter of a function I have stubbed I see in logs that my stub is called successfully, and I want to change on of the paramters and run the original function. Can I do that with OCMock?

Here's what I'm doing:

.... 

id testMgrMock = [OCMockObject partialMockForObject:testClassInstance];

OCMStub([testMgrMock addRequestWithMethod:OCMOCK_ANY
                                     path:OCMOCK_ANY
                               parameters:OCMOCK_ANY
                                  headers:OCMOCK_ANY
                                     body:OCMOCK_ANY
                                 delegate:OCMOCK_ANY
                             successBlock:OCMOCK_ANY
                             failureBlock:OCMOCK_ANY]).
andDo(^(NSInvocation* invocation){
    NSString* path = @"http://addressnotexi.st";
    [invocation setArgument:&path atIndex:2];
    [invocation invoke];
});
......

the line [invocation invoke]; gives me bad_exec crash. Even if I don't change the parameter.

How to do it properly? Is it possible at all?

Thank you

Aucun commentaire:

Enregistrer un commentaire