Kiwi Spec 单元测试:实例方法“-attachToVerifier:verifier:”未找到
我正在构建一些 Kiwi 测试并收到一个我无法解释的警告。我是猕猴桃的新手。
我有一个模拟对象设置:
id conversationMock = [KWMock mockForProtocol:@protocol(Conversation)];
[conversationMock stub:@selector(end)];
在我的控制器中,有一个名为“conversation”的属性:
@interface MyController ()
@property (nonatomic, assign) id<Conversation> conversation;
@end
模拟被分配给该属性,然后在规范中我检查对话中是否调用了方法“end”:
it(@"should end conversation", ^{
[[[myController.conversation] should] receive] end];
[myController stopTalking];
});
编译器(LLVM 3.0)显示警告:“找不到实例方法'-attachToVerifier:verifier:'”
这是什么原因?这是我需要解决的问题吗? (测试运行正常,检查方法调用结束是否正常)
I'm building some Kiwi tests and getting a warning that I cannot explain. I'm new to Kiwi.
I have a mock object setup:
id conversationMock = [KWMock mockForProtocol:@protocol(Conversation)];
[conversationMock stub:@selector(end)];
And in my controller, a property called "conversation":
@interface MyController ()
@property (nonatomic, assign) id<Conversation> conversation;
@end
The mock is assigned to the property, then in the spec I check for whether the method "end" is called on the conversation:
it(@"should end conversation", ^{
[[[myController.conversation] should] receive] end];
[myController stopTalking];
});
The compiler (LLVM 3.0) is showing a warning: "Instance method '-attachToVerifier:verifier:' not found"
What is the cause of this? Is this something I need to fix? (test runs ok, checks the method call to end works ok)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将 id 类型转换为 NSObject 可以消除警告:
[[(NSObject*)[myController.conversation] should] receive] end];
Typecasting the id to a NSObject gets rid of the warning:
[[(NSObject*)[myController.conversation] should] receive] end];
您需要做的是:
添加标志:
-all_load
What you need to do is:
Add the flag:
-all_load
根据 @Komposr 的回答,我查看了几个 Kiwi 项目,发现我需要执行以下操作:
添加标志:-ObjC
注意,我不使用 CocoaPods。我已经下载并编译了 Kiwi 作为静态库,我将其包含在内......
Based on @Komposr's answer, I looked at a couple of my projects with Kiwi and found that I needed to do the following:
add the flag: -ObjC
Note that I am NOT USING CocoaPods. I have downloaded and compiled Kiwi as a static library that I am including...