简体   繁体   English

C ++ CXX测试框架

[英]CXX Test Framework for C++

How effective is the CXX test framework, given that you are writing unit test cases around the code that you have written. 假设您正在围绕编写的代码编写单元测试用例,那么CXX测试框架的有效性如何。 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. 而且,花费在CXX上的时间和精力至少等于或者不大于编码工作。

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 :). 另一方面,如果您认为这是有益的,请告诉我:)。

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. 谷歌提供,我是用一个美妙的C ++测试框架......我从来没有使用过任何其他C ++测试框架,并且有经验有限使用JUnit,我是能够非常迅速回暖这件事,因为文档是好的。 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/ http://code.google.com/p/googletest/

Hope this helps! 希望这可以帮助!

CXX is not very active, and writing unit test generally involves a lot of efforts. CXX不是很活跃,编写单元测试通常需要付出很多努力。 But when the first refactoring comes in, you're very grateful of the spent effort. 但是,当第一次进行重构时,您将非常感谢您所付出的努力。

I've used Boost.Test & CPPUNIT. 我用过Boost.Test和CPPUNIT。 I would prefer a little bit Boost.Test, but yes, you have to write your own projects, files etc. 我希望使用Boost.Test,但是,您必须编写自己的项目,文件等。

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. 我建议您尝试使用Boost.Test和CPPUNIT。 If you think there are better it will give you good rounds to oppose CXXUNIT as you will propose alternatives. 如果您认为有更好的选择,它将为您提供反对CXXUNIT的良好机会,因为您将提出替代方案。

I am using cxxtest. 我正在使用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. 我们将cxxtest与覆盖率分析结合在一起,以确保测试覆盖率足够,并与CruiseControl自动化。

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 我认为乔尔对此也有话要说: http : //www.joelonsoftware.com/items/2009/01/31.html

I prefer header-only test frameworks, here are two of them: TUT and Catch . 我更喜欢仅标头的测试框架,这是其中的两个: TUTCatch I used TUT before in several projects, and found Catch not long ago. 我之前在多个项目中使用过TUT ,不久前发现Catch

1) TUT -- C++ Template Unit Test Framework 1) TUT -C ++模板单元测试框架

TUT is a small and portable unit test framework for C++. TUT是用于C ++的小型便携式单元测试框架。

  • TUT is very portable, no matter what compiler or OS you use. 无论您使用哪种编译器或OS,TUT都非常易于移植。
  • TUT consists of header files only. TUT仅包含头文件。 No libraries required, deployment has never been easier. 无需库,部署从未如此简单。
  • Custom reporter interface allows to integrate TUT with virtually any IDE or tool in the world. 自定义报告器界面允许将TUT与世界上几乎所有的IDE或工具集成。
  • Support for multi-process testing (testing deadlocks and timeouts is under way). 支持多进程测试(正在测试死锁和超时)。
  • TUT is free and distributed under a BSD-like license. TUT是免费的,并根据类似BSD的许可证进行分发。
  • Tests are organised into named test groups. 测试分为命名的测试组。
  • Regression (all tests in the application), one-group or one-test execution. 回归(应用程序中的所有测试),一组或一次测试执行。
  • Pure C++, no macros! 纯C ++,没有宏!

2) Catch -- A modern, C++-native, header-only, framework for unit-tests, TDD and BDD 2) 捕获 -用于单元测试,TDD和BDD的现代,C ++原生,仅标头的框架

What's the Catch? 什么是渔获?

Catch stands for C++ Automated Test Cases in Headers and is a multi-paradigm automated test framework for C++ and Objective-C (and, maybe, C). Catch代表标题中的C ++自动化测试用例,是针对C ++和Objective-C(也许还有C)的多范式自动化测试框架。 It is implemented entirely in a set of header files, but is packaged up as a single header for extra convenience. 它完全在一组头文件中实现,但打包成单个头可带来更多便利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM