0
我正在使用OCMock 3進行單元測試。我有一個名爲processInfo
一個很簡單的功能測試:在單元測試中捕獲多個參數
@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{
...
}
我的測試情況下應該是這樣的捕捉參數(由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?
}]]);
我上面鏈接的答案告訴如何使用[OCMArg checkWithBlock:^(id value)]
捕獲單個參數,但我想捕獲兩個參數。那麼怎麼做呢?
一般情況下,我很難找到互聯網上有據可查的路該怎麼捕獲多個參數與OCMock V3單元測試。任何人都知道如何做到這一點?