OCMockito单元测试 - 如何验证已调用带原语的方法?

时间:2014-07-15 20:57:46

标签: ios objective-c unit-testing ocmockito

如何验证使用OCMockito创建的模拟对象是否已收到带有原始参数的方法调用?

我尝试测试的方法是setProgress:(float)progress

    CompositeProgressView* mockProgress = mock([CompositeProgressView class]);
    self.downloader.progressView = mockProgress;
//run a task that increments progress
...
//test
    [verify(mockProgress) setProgress:anything()]; //does not work

1 个答案:

答案 0 :(得分:0)

[[verify(mockProgress) withMatcher:anything()] setProgress:0];

在&#34中描述;如何为原始参数指定匹配器?"在https://github.com/jonreid/OCMockito

希望有所帮助!