0
我正在爲返回NSMutableAttributedString的方法中的「if」語句編寫單元測試,並且出現一些錯誤。在NSMutableAttributedString上設置期望值
爲IF語句實際代碼:
if (conditionIsTrue)
{
return [[NSMutableAttributedString alloc] initWithString:NSLocalizedStringWithDefaultValue(@"ABC",
@"ABCLibrary",
[NSBundle bundleWithName:@"ABCLibraryResources"],
@"No ABC",
@"No ABC String")
attributes:[self methodA]];
}
單元測試:
ControllerA *controller = [[ControllerA alloc] init];
id mockController = [OCMockObject partialMockForObject:controller];
NSMutableAttributedString *temp = [[NSMutableAttributedString alloc] initWithString:NSLocalizedStringWithDefaultValue(@"ABC",
@"ABCLibrary",
[NSBundle bundleWithName:@"ABCLibraryResources"],
@"No ABC",
@"No ABC String")
attributes:[self methodA]];
[[mockController expect] temp];
錯誤:
No known instance method for selector temp.
我是否設置錯誤的期望?我如何設置NSMutableAttributedString的期望值?