C++ 的单元测试框架不需要预处理代码
有几个主要的单元测试框架,但据我所知,它们都需要以某种方式处理源代码。
例如,我正在使用 cxxunit,它需要使用一些 python 脚本来处理单元测试。这样做的问题是它增加了构建时间。
有谁知道 C++ 代码的单元测试框架不预处理单元测试代码?
PS:我需要Linux,但如果是多平台就可以了。
There are several major unit tests frameworks, but as far as I know all of them needs to process the source code in some way.
For example, I am using cxxunit, and it requires the unit tests to be processed using some python script. The problem with this is that it increases the build time.
Does anyone know of a unit testing framework for C++ code that doesn't preprocess the unit tests code?
PS: I need it for linux, but it is ok if it is multi platform.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用
Boost.Test
。我对此有很好的经验。它不需要任何特殊的预处理。You could use
Boost.Test
. I've had good experiences with it. It does not require any special preprocessing.您可以使用 Google 测试 框架。您只需构建一次库源代码。然后,您可以将测试创建为
.cpp
文件,然后将它们与gtest
和所需的项目库作为普通 C++ 源进行编译和链接。除此之外,它是多平台的。
You could use google test framework. You need just build library source code one time. Then you can create your tests as
.cpp
files, then compile and link them withgtest
and needed project libraries as ordinary c++ sources.Besides that, it is multiplatform.
我对 googletest 感到满意。
I'm happy with googletest.
CPPUnit 是我目前个人的选择,并且是纯 C++ 语言。
CPPUnit is my personal choice at the moment, and is in plain C++.
我一直在使用测试狗。您可以使用要测试的代码构建测试,它会生成 HTML 输出摘要。
I've been using TestDog. You construct your tests using the code to test and it produces HTML output summaries.
我建议您在评估中也考虑 Andrew Marlow 的 FRUCTOSE http://fructose.sourceforge.net/ 。他是一位非常彻底和专业的开发人员,在制作自己的产品之前会仔细比较现有的产品。另请参阅讨论该库的 ACCU 文章:http://accu.org/index.php/journals/第1305章
I'd recommend considering Andrew Marlow's FRUCTOSE http://fructose.sourceforge.net/ in your evaluation too... he's a very thorough and professional developer who compared existing offers carefully before crafting his own. See also an ACCU article disucssing the library: http://accu.org/index.php/journals/1305