如何为框架配置 OCUnit 测试包?
我一直在开发 Mac OS X 框架,并且想在我的 XCode 3.2.1 项目中使用 OCUnit。我遵循了几个有关如何配置 OCUnit 测试包的教程。问题是,当我创建一个使用框架源之一中定义的函数的测试用例时,我收到一个构建错误,告诉我找不到该符号。
正如教程所述,我使测试包依赖于我的项目的目标,但这似乎不是问题。首先,我认为可以通过将框架的源文件拖到测试包目标中的编译源部分来解决这个问题,但随后从该源文件引用的所有符号开始显示在构建错误中,因此这似乎不是是一个好的解决方案/想法。
如何配置我的单元测试包以便正确构建?
I've been developing a Mac OS X framework and I want to use OCUnit in my XCode 3.2.1 project. I've followed several tutorials on how to configure a OCUnit test bundle. The problem is that when I create a test case that uses a function that is defined in one of the framework's sources, I get a building error telling me that the symbol is not found.
I made the test bundle dependent of my project's target as the tutorial said, but that doesn't seem to be problem. First I thought that I could solve this problem by dragging the framework's source files into the compile sources section within the Test bundle target, but then all the symbols referenced from that source file started to show up in the build errors, so that seems to not be a good solution/idea.
How can I configure my unit test bundle so it builds properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还针对框架编写单元测试,希望能有所帮助。您不想重新编译框架源以进行单元测试 - 相反,您希望链接到构建的框架。我的建议如下:
+
符号添加链接库。选择您的项目生成的框架并单击“添加”。关闭信息窗口。#import "MyHeader.h"
形式,而不是尖括号(<
和> ;
)。此时,您的单元测试应该正确无误地构建。如果没有,也许检查我的单元测试如何配置 CHDataStructures 会有所帮助。
I also write unit tests against a framework, hopefully I can help. You don't want to recompile framework sources for unit testing — instead, you want to link against the built framework. Here's what I suggest:
+
sign in the lower left to add a linked library. Select the framework which your project generates and click "Add". Close the info window.#import "MyHeader.h"
form, rather than angle brackets (<
and>
).At this point, your unit tests should build without error. If not, perhaps examining how my unit tests are configured for CHDataStructures can help.
我可以通过单击 Xcode 主窗口中出现的文件查看器表中与我的框架(出现在产品部分中的那个)相对应的复选框来使其工作(我猜它将文件作为目标 o 类似那)。看来将框架拖到单元测试包会做不同的事情。
I could make it work by clicking on the checkbox corresponding to my framework(the one that appears in the product section) in the file viewer table that appears in the main windows of Xcode (I guess it put the file as a target o something like that). It seems that dragging the framework to the Unit Test bundle does a different thing.