OCMockito 如何捕获块并匹配任何其他原始参数?

OCMockito how to capture block and match any other primitive arguments?

方法签名:

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

我尝试捕获成功块参数并忽略其他类似参数:

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

我只想用我的 json:

调用成功块
SuccessBlock block = captor.value;
block(json);

但我得到的只是 argument(s) are different! 错误。 我可以为其他参数做些什么?

在 OCMockito 文档中,请参阅 How do you specify matchers for non-object arguments?

因此您需要指定

[[[[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()];