C ++单元测试框架 [英] C++ unit testing framework

查看:108
本文介绍了C ++单元测试框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的C ++代码使用Boost测试框架,但它有两个问题,它们可能是所有C ++测试框架的常见问题:

I use the Boost Test framework for my C++ code but there are two problems with it that are probably common to all C++ test frameworks:


  • 没有办法创建自动测试存根(例如通过从选定的类中提取公共函数)。

  • 您不能运行单个测试 - 您必须运行整个 (除非你创建了很多不同的测试项目)。

有没有人知道更好的测试框架,嘲笑Java / .NET开发人员可用的测试工具。

Does anyone know of a better testing framework or am I forever to be jealous of the test tools available to Java/.NET developers?

推荐答案

我只是回应了非常类似的问题。我最后使用Noel Llopis的UnitTest ++。我喜欢它比boost :: test更好,因为它不坚持用宏来实现测试工具的主程序 - 它可以插入任何可执行文件创建。它确实遭受了与boost :: test相同的阻碍,因为它需要一个库被链接。我使用CxxTest,它确实比任何其他在C ++中更接近自动生成测试(虽然它需要Perl成为你的构建系统的一部分来做到这一点)。 C ++只是不提供.NET语言和Java做的反射钩子。 Visual Studio Team System - Developer's Edition中的MsTest工具将自动生成非托管C ++的测试桩,但这些方法必须从DLL导出才能执行此操作,因此它不能用于静态库。 .NET世界中的其他测试框架也可能有这种能力,但我不熟悉任何这些。所以现在我们使用UnitTest ++非托管C ++,我目前决定在MsTest和NUnit之间的托管库。

I just responded to a very similar question. I ended up using Noel Llopis' UnitTest++. I liked it more than boost::test because it didn't insist on implementing the main program of the test harness with a macro - it can plug into whatever executable you create. It does suffer from the same encumbrance of boost::test in that it requires a library to be linked in. I've used CxxTest, and it does come closer than anything else in C++-land to automatically generating tests (though it requires Perl to be part of your build system to do this). C++ just does not provide the reflection hooks that the .NET languages and Java do. The MsTest tools in Visual Studio Team System - Developer's Edition will auto-generate test stubs of unmanaged C++, but the methods have to be exported from a DLL to do this, so it does not work with static libraries. Other test frameworks in the .NET world may have this ability too, but I'm not familiar with any of those. So right now we use UnitTest++ for unmanaged C++ and I'm currently deciding between MsTest and NUnit for the managed libraries.

这篇关于C ++单元测试框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆