0

我使用Visual Studio 2012的CppUnitTestFramework进行单元测试我的C++代码。现在我想用Visual Leak Detector检查内存泄漏。所以我把视觉泄漏检测器不能在VS2012中使用单元测试

#include "vld.h" 

到我的测试类文件。我添加了一些像

new MyClass(); 

以“模拟”内存泄漏的测试方法。

所有编译和链接都很好,这意味着指定了VLD目录。但测试崩溃:

------ Run test started ------ 
The active Test Run was aborted because the execution process exited unexpectedly. To investigate further, enable local crash dumps either at the machine level or for process vstest.executionengine.x86.exe. Go to more details: http://go.microsoft.com/fwlink/?linkid=232477 
========== Run test finished: 0 run (0:00:02,3841194) ========== 

当我删除include指令测试通过成功。有没有办法将VLD与Visual Studio测试框架一起使用?

回答

1

我有一个类似的问题,通过将vld bin目录中的Microsoft.DTfW.DHL.manifest复制到单元测试可执行文件目录中解决了这个问题。

+0

请问单元测试可执行文件目录在哪里? – TobiMcNamobi 2013-05-02 15:18:07

+0

奇怪。我试图将它复制到Microsoft Visual Studio 11.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow中。有一段时间,这确实有效(尽管我不知道是否需要重新启动VS)。我可以运行这些测试,并在调试它们时收到内存泄漏报告。但之后突然停止工作。我做的最后一件事是评论整个测试课程。无论如何,之后,我再次尝试修复它是成功的。我回到“这只是不工作”。 – TobiMcNamobi 2013-05-03 07:35:47