0

method signature:

- (void)updateFeaturesButtons:(NSInteger)gameId
                 category:(FeatruesCategory)category
                 parentId:(NSInteger)parentId
                  success:(void (^)(NSDictionary* featuresJson))success
                  failure:(void (^)(NSError* error))failure

I try to capture the success block argument and ignore other arguments like that:

HCArgumentCaptor* captor = [[HCArgumentCaptor alloc] init];
[verify(mockManager) updateFeaturesButtons:0 category:0 parentId:0 success:(id)captor failure:anything()];

I just want to call success block with my json:

SuccessBlock block = captor.value;
block(json);

But what I get is only argument(s) are different! error. What can I do for other arguments?

ccnyou
  • 337
  • 2
  • 11

1 Answers1

2

In the OCMockito documentation, see How do you specify matchers for non-object arguments?

So you'll need to specify

[[[[verify(mockManager)
    withMatcher:anything() forArgument:0]
    withMatcher:anything() forArgument:1]
    withMatcher:anything() forArgument:2]
    updateFeaturesButtons:0 category:0 parentId:0 success:(id)captor failure:anything()];
Jon Reid
  • 20,545
  • 2
  • 64
  • 95
  • 1
    I have read the ocmockito documentation, but I don't see any example to match more than 2 arguments with `withMatcher`. It works, thanks! – ccnyou Nov 18 '16 at 02:58