Kiwi Spec 单元测试:实例方法“-attachToVerifier:verifier:”未找到

发布于 2024-12-21 21:52:31 字数 693 浏览 1 评论 0原文

我正在构建一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏九 2024-12-28 21:52:31

将 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];

偷得浮生 2024-12-28 21:52:31

您需要做的是:

build settings -> Other Linker flags

添加标志:-all_load

What you need to do is:

build settings -> Other Linker flags

Add the flag: -all_load

岁月如刀 2024-12-28 21:52:31

根据 @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:

Build Settings -> Other Linker Flags

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文