我对应该调用完成块或失败块的方法进行了单元测试。现在我知道每种情况应该调用哪个,所以我STFail
在不应该调用的块中使用。
我现在如何测试应该调用的块是否真的被调用了?
这是我的设置:
NSString *parameter = @"foo";
[controller doSomethingWithParameter:parameter withcompletionBlock:
^(NSString *result)
{
// This block should be invoked
// Check if the result is correct
STAssertEquals(result, kSomeOKConstant, @"Result shout be 'kSomeOKConstant'");
} failedBlock:
^(NSString *errorMessage) {
STFail(@"No error should happen with parameter '%@'",parameter);
}];