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