本文介绍了如何在Visual Studio 2012中将单元测试添加到C ++控制台程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio 2012中将单元测试添加到C ++控制台程序?

How can I add a unit test to a C++ console program in Visual Studio 2012?

我从MSDN收集的MS单元测试支持C ++不能这样做(这不奇怪我,因为MS C ++单元测试支持总是令人震惊)。

From what I've been able to gather from the MSDN the MS unit test support for C++ can't do this at all, (which doesn't surprise me as the MS C++ unit test support was always shocking).

然而在早期版本的Visual Studio你曾经能够使用Visual Assist单元测试C ++代码,但可惜的是这不支持vs2012。

However in earlier versions of Visual Studio you used to be able to unit test C++ code using Visual Assist, but sadly this doesn't support vs2012.

有人知道一个C ++单元测试框架有一些IDE集成可以与vs2012一起使用?

Does anyone know of a C++ unit test framework with some sort of IDE integration that works with vs2012?

推荐答案

Visual studio支持。你需要正确的结构你的程序。我喜欢构建我的解决方案的方式是有三个项目。

Visual studio does support integrated unit testing. You need to structure your program correctly though. The way I like to structure my solutions is to have three projects.


  • 其中包含我的源代码的.lib项目。

  • 与.lib。这会调用main()调用中的.lib。

  • 与.lib链接的测试项目(exe)。

虽然可以使用Visual Studio测试框架,但我建议您。关于Google测试的最好的事情之一是实际上是。您可以与此进行一些集成。

Whilst it is possible to use the Visual Studio testing framework, I would recommend Google test. One of the best things about google test is actually Google mock. You can get some integration with this plugin.

这篇关于如何在Visual Studio 2012中将单元测试添加到C ++控制台程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 05:34