Reputation: 42692
I am using OCMock 3 to do unit testing. I have a very simple function named processInfo
to test:
@implementation MyService
// in my test case, I want to test this function
-(void) processInfo{
...
[self handleDataWith:infoData name:someName];
}
-(void) handleDataWith:(NSData*)data name:(NSString*)name{
...
}
My test case is supposed to be something like this to capture argument (inspired by this answer):
-(void) testProcessInfo {
id serviceMock = [OCMockObject mockForClass:[MyService class]];
// Wow!Wow! wait, the answer I linked above only talk about how to capture a single argument,
//BUT I have two arguments to capture, how to do then?
OCMExpect([serviceMock handleDataWith:[OCMArg checkWithBlock:^(id value){
// Capture argument here...but what about several arguments?
}]]);
The answer I linked above tells how to use [OCMArg checkWithBlock:^(id value)]
to capture a single argument, but I want to capture two arguments. How to do it then?
In general, I can hardly find a well documented way on internet about how to capture multiple arguments in unit test with OCMock v3. Anyone knows how to do this?
Upvotes: 0
Views: 334
Reputation: 3016
As I mentioned in a comment to the answer to one of your other questions (Check argument value passed into function in unit test), you have to use andDo
.
Upvotes: 0