C++ 的 CXX 测试框架
考虑到您正在围绕您编写的代码编写单元测试用例,CXX 测试框架的有效性如何。 代码中的任何错误也可能会转化为单元测试代码中的错误吗? 这不是就像两个负数变成正数一样吗?
此外,花在 CXX 上的时间和精力至少等于(如果不超过)编码工作。
需要您对此的想法,因为我不赞成在我的项目中使用这个框架,并且正在寻找反对它的优点。
另一方面,如果您认为它有益,请启发我:)。
How effective is the CXX test framework, given that you are writing unit test cases around the code that you have written. Any bug in the code might as well get translated into a bug in the unit test code as well? Isn't it something like two negatives make a positive?
Also, the time and effort spent on CXX is at least equal to if not more than the coding effort.
Need your thoughts on this since I'm not in favor of this framework being used in my project and am looking for strong points to oppose it.
On the other hand, if you think it's beneficial, please do enlighten me :).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Google 提供了一个我用过的很棒的 C++ 测试框架...我从未使用过任何其他 C++ 测试框架,并且对 Junit 的使用经验有限,而且我能够非常< /em> 很快,因为文档很好。 使用一个好的测试框架很重要,因为测试太重要了,不能因为对框架感到失望而放弃。 这是一个链接:
http://code.google.com/p/googletest/
希望这可以帮助!
Google offers a fantastic C++ testing framework that I have used... I never used any other C++ testing framework, and had limited experience with Junit, and I was able to pick this up very quickly, as the documentation is good. It's important to use a good testing framework, because testing is too important to give up on because of frustration with the framework. Here is a link:
http://code.google.com/p/googletest/
Hope this helps!
CXX不是很活跃,编写单元测试一般需要付出很大的努力。 但当第一次重构开始时,你会非常感激所付出的努力。
我用过 Boost.Test & CPPUNIT。 我更喜欢一点 Boost.Test,但是,是的,您必须编写自己的项目、文件等。
如果您知道一个从代码生成骨架的工具,我会洗耳恭听。 :)
我建议你尝试一下 Boost.Test 和 CPPUNIT。 如果您认为有更好的方案,那么您将有机会反对 CXXUNIT,因为您将提出替代方案。
CXX is not very active, and writing unit test generally involves a lot of efforts. But when the first refactoring comes in, you're very grateful of the spent effort.
I've used Boost.Test & CPPUNIT. I would prefer a little bit Boost.Test, but yes, you have to write your own projects, files etc.
If you know a tool to generate your skeleton from your code, I'm all ears. :)
I would suggest that you give a try to Boost.Test and CPPUNIT. If you think there are better it will give you good rounds to oppose CXXUNIT as you will propose alternatives.
我正在使用 cxxtest。 回归测试是一项昂贵的任务,我们仅使用它来验证我们的软件库 - 它为我们的应用程序提供了一个独立于平台的层。 这是为了确保所有更改都不会影响代码的稳定性,因为有如此多的应用程序和项目依赖于它们。
我们将 cxxtest 与覆盖率分析结合起来,以确保测试覆盖率足够,并与 CruiseControl 结合起来以实现自动化。
但我们不会为应用程序这样做。 太费力了。
构建测试应用程序与编写整个库本身一样困难。 我同意你需要弄清楚这是否值得你花时间。
我想乔尔对此也有话要说:
http://www.joelonsoftware.com/items/2009/01/31。 html
I am using cxxtest. Regressive testing is an expensive task that we only use to validate our software libraries - which provide a platform independent layer for our apps. This is to ensure that all changes will not affect the stability of the code since so many apps and projects and dependent on them.
We couple cxxtest with coverage analysis to ensure that test coverage is sufficient and also with CruiseControl to automate it.
But we do not do this for apps. Too much effort.
Building a test app is just as difficult as writing the whole library itself. I agree that you will need to work out whether it is worth your while.
I think Joel has something to say about this too:
http://www.joelonsoftware.com/items/2009/01/31.html
我更喜欢仅标头的测试框架,这里有两个: TUT 和 Catch 。 我之前在几个项目中使用过TUT,并发现Catch 不久前。
1) TUT -- C++模板单元测试框架
2) Catch -- 一个现代的、C++ 原生的、仅包含头文件的单元测试框架,TDD和 BDD
I prefer header-only test frameworks, here are two of them: TUT and Catch . I used TUT before in several projects, and found Catch not long ago.
1) TUT -- C++ Template Unit Test Framework
2) Catch -- A modern, C++-native, header-only, framework for unit-tests, TDD and BDD