문제

I want to write unit tests using Google Test / Mock for code in my DLL. The test code is supposed to be compiled into my DLL.

I read in the Google Test Primer that this is possible, but that gtest has to be compiled into a DLL then (and I guess the same thing holds for gmock, too).

Has anybody compiled and used the framework as DLL's and can tell me the most important project settings (I use VS2010) and how to use the resulting DLL's to run the tests?

도움이 되었습니까?

해결책

GoogleTest and GoogleMock do not need to be compiled into a .dll.

Rather it is saying that they need to be compiled with the same Runtime Library setting as the project consuming (linking) them (/MD or /MT). Runtime Library Settings

Consistency is the key! When linking any library (LIB or DLL), they should have the same Runtime Library setting as the project (or vice versa).

Runtime Library Options

I would also recommend using the same Character Set setting.

다른 팁

Set preprocessor flag (properties->c/c++->Preprocessor->Preprocessor Definitions) GTEST_CREATE_SHARED_LIBRARY to build the Gmock as dll, and build the dll that consumes gmock with GTEST_LINKED_AS_SHARED_LIBRARY

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top