Xcode 4 中的 OCUnit 和 C++? [英] OCUnit and C++ in Xcode 4?

查看:62
本文介绍了Xcode 4 中的 OCUnit 和 C++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人成功地将 OCUnit(如在 Xcode 4.2 单元测试中)与 C++ 代码一起使用?

Is anybody using OCUnit (as in Xcode 4.2 Unit Testing) with C++ code successfully?

经过几个小时的尝试了解正在发生的事情后,我现在非常确信使用 Xcode 4 和 OCUnit 测试来自 Objective-C++ 文件 (.mm) 的 C++ 代码存在一些重大缺陷

After hours trying to understand what's going on I'm now pretty convinced there are some major flaws in using Xcode 4 and OCUnit to test C++ code from Objective-C++ files (.mm)

主应用程序(带有一些 C++ 业务逻辑的 Cocoa)编译得很好!微不足道的 .mm 测试类失败,出现奇怪的编译器错误,不同

The main application (Cocoa with some C++ business logic) compiles fine! The trivial .mm test class fails with weird compiler errors, varying between

  • 使用未声明的标识符(C++ 类名)
  • 使用不完整的类型
  • C++ 要求所有声明都使用类型说明符

等等.基本上它似乎与 C++ 位非常混淆.测试文件抱怨的类从主应用程序编译得很好!它们可以在主应用程序中实例化就好了.

and so forth. Basically it seems to be terribly confused with the C++ bits. The classes the test files complain about compile JUST FINE from the main application! They can be instantiated in the main application JUST FINE.

有人遇到过并解决过这个问题吗?

Anybody having encountered and solved this before?

谢谢,杰

推荐答案

当我使用 OCUnit 对 C++ 代码进行单元测试时,我必须使 C++ 实现文件成为单元测试目标的成员才能使单元测试正常工作.从项目导航器中选择一个 C++ 文件并打开文件检查器.文件检查器中应该有一个 Target Membership 部分.Target Membership 部分有一个项目目标列表,每个目标旁边都有一个复选框.选中单元测试目标旁边的复选框,使文件成为单元测试目标的成员.

When I unit tested C++ code with OCUnit, I had to make the C++ implementation files members of the unit test target to get unit tests to work. Select a C++ file from the project navigator and open the file inspector. There should be a Target Membership section in the file inspector. The Target Membership section has a list of your project's targets with a checkbox next to each target. Select the checkbox next to the unit test target to make the file a member of the unit test target.

这篇关于Xcode 4 中的 OCUnit 和 C++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆