如何为 Visual Studio C++ 设置单元测试

我无法弄清楚如何在 Visual Studio 2008 中为 C++ 设置和使用测试框架,大概是内置的单元测试套件.

I'm having trouble figuring out how to get the testing framework set up and usable in Visual Studio 2008 for C++ presumably with the built-in unit testing suite.

任何链接或教程将不胜感激.

Any links or tutorials would be appreciated.

推荐答案

这个页面可能会有所帮助,它回顾了很多 C++ 单元测试框架:

This page may help, it reviews quite a few C++ unit test frameworks:

  • CppUnit
  • Boost.Test
  • CppUnitLite
  • NanoCppUnit
  • 单元++
  • CxxTest

查看CPPUnitLite 或 CPPUnitLite2.

CPPUnitLite 由 Michael Feathers 创建,他最初将 Java 的 JUnit 作为 CPPUnit 移植到 C++ 中(CPPUnit 尝试模仿 JUnit 的开发模型 - 但 C++ 缺乏 Java 的特性 [例如反射] 使其易于用).

CPPUnitLite was created by Michael Feathers, who originally ported Java's JUnit to C++ as CPPUnit (CPPUnit tries mimic the development model of JUnit - but C++ lacks Java's features [e.g. reflection] to make it easy to use).

CPPUnitLite 试图制作一个真正的 C++ 风格的测试框架,而不是一个移植到 C++ 的 Java.(我是从 Feather 的 有效地使用旧代码书).CPPUnitLite2 似乎是另一种重写,具有更多功能和错误修复.

CPPUnitLite attempts to make a true C++-style testing framework, not a Java one ported to C++. (I'm paraphrasing from Feather's Working Effectively with Legacy Code book). CPPUnitLite2 seems to be another rewrite, with more features and bug fixes.

我还偶然发现了 UnitTest++ 其中包括来自 CPPUnitLite2 和其他一些框架的内容.

I also just stumbled across UnitTest++ which includes stuff from CPPUnitLite2 and some other framework.

Microsoft 已发布 WinUnit.

Microsoft has released WinUnit.

也结帐Catch 或 Doctest

相关文章