Unit testing non-exported classes in a DLL

前端 未结 4 1417
执笔经年
执笔经年 2021-01-31 09:05

We develop a C++ application using Visual Studio 2008 and unit test using Boost.Test. At the moment, we have a separate solution which contains our unit tests.

Many of o

4条回答
  •  一生所求
    2021-01-31 09:35

    Try making a define such as the following somewhere all files will include:

    #define EXPORTTESTING __declspec(dllexport)
    

    And use it in place of the dllexport, like this:

    class EXPORTTESTING Foo 
    {
     ...
    };
    

    Then you will be able to turn off the flag for building a release DLL, but keep it on for a unit-testable DLL.

提交回复
热议问题