GoogleMock issue with Visual Studio 2010 and MSTest (C++/CLI)
Our product previously built in Visual Studio 2008 and used GoogleMock 1.5.0.
Now, after porting our product to Visual Studio 2010, any unit test DLL that uses GoogleMock will not load in visual Studio's Test View and consequently can't be executed.
Our production code is written in native C++ classes exported from C++ DLLs.
Our unit tests are written in C++/CLI so they can be hosted directly within Visual Studio. The C++/CLI unit tests exercise our native C++ classes, and GoogleMocks previously played quite happily in this scenario.
We build GoogleMock into static libs that use Multithreaded DLL at run time. All our production code also uses Multithreaded DLL.
We have tried GoogleMock 1.5 and 1.6 RC, both rebuilt within VS2010. But the problem arises with both versions of GoogleMock.
To reproduce, simply:
- Create a new C++ Unit Test project
- Add gmock.lib and gmock_main.lib as linker inputs
#include <gmock/gmock.h>
at the top of the C++/CLI unit test header file.
The project will build fine, but the VS Test View cannot load the new unit test DLL. If you comment out the gmock.h
inclusion, the DLL will load in Test View and its test fixtures will execute.
I am hoping that another VS2010 developer has encountered this problem and can suggest a fix.
My set-up:
- Windows 7 x64
- Visual Studio 2010, Service Pack 1
- Googl开发者_开发知识库eMock 1.5, or 1.6 RC
- Our app is built as 32-bit (Win32 and x86).
- All our C++ code, including GoogleMock, is compiled using VS2010's vc100 compiler. Our C++/CLI code is also built for .NET 4.0.
Thanks.
Having the same code setup as dripfeed (using Google Mock to test c++ native classes with MSTest), we got Google Mock 1.6 to work by building Google Mock with the /CLR compilation setting.
We now have successfully implemented some tests with Google Mock!
Note: Putting the /CLR setting may require to adjust other compilation settings.
I think I read somewhere on the documentation that it is a Microsoft's bug...
精彩评论