我正在为返回 NSMutableAttributedString 的方法中的“if”语句编写单元测试,但出现了一些错误。
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 设置期望值?