我正在为返回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设置expect?
发布于 2013-06-18 19:40:14
[[mockController expect] temp] 告诉mockController应该调用方法temp。在这里,临时只是一个变量。你真正想要的是
[[[mockController expect] andReturn:temp ] theMethodThatYouHaveTheIfStatementIn]https://stackoverflow.com/questions/13364266
复制相似问题