C++ 的 CXX 测试框架

发布于 2024-07-17 04:07:29 字数 223 浏览 5 评论 0原文

考虑到您正在围绕您编写的代码编写单元测试用例,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

今天小雨转甜 2024-07-24 04:07:29

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!

新雨望断虹 2024-07-24 04:07:29

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.

清醇 2024-07-24 04:07:29

我正在使用 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

二手情话 2024-07-24 04:07:29

我更喜欢仅标头的测试框架,这里有两个: TUTCatch 。 我之前在几个项目中使用过TUT,并发现Catch 不久前。

1) TUT -- C++模板单元测试框架

TUT 是一个小型、可移植的 C++ 单元测试框架。

  • 无论您使用什么编译器或操作系统,TUT 都非常可移植。
  • TUT 仅由头文件组成。 无需库,部署从未如此简单。
  • 自定义报告器界面允许将 TUT 与世界上几乎任何 IDE 或工具集成。
  • 支持多进程测试(死锁和超时测试正在进行中)。
  • TUT 是免费的,并在类似 BSD 的许可证下分发。
  • 测试被组织成命名的测试组。
  • 回归(应用程序中的所有测试)、一组或一项测试执行。
  • 纯C++,没有宏!

2) Catch -- 一个现代的、C++ 原生的、仅包含头文件的单元测试框架,TDD和 BDD

有什么问题?

Catch 代表标头中的 C++ 自动测试用例,是一个
C++ 和 Objective-C 的多范式自动化测试框架(以及,
也许,C)。 它完全在一组头文件中实现,但是
打包为单个标头以提供额外的便利。

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

TUT is a small and portable unit test framework for C++.

  • TUT is very portable, no matter what compiler or OS you use.
  • TUT consists of header files only. No libraries required, deployment has never been easier.
  • Custom reporter interface allows to integrate TUT with virtually any IDE or tool in the world.
  • Support for multi-process testing (testing deadlocks and timeouts is under way).
  • TUT is free and distributed under a BSD-like license.
  • Tests are organised into named test groups.
  • Regression (all tests in the application), one-group or one-test execution.
  • Pure C++, no macros!

2) Catch -- A modern, C++-native, header-only, framework for unit-tests, TDD and BDD

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). It is implemented entirely in a set of header files, but is
packaged up as a single header for extra convenience.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文