0

I am trying to write unit tests for a larger, old project using GTest. The project compiles as a dll. Here is what the setup looks like: There are several projects inside the solution, and I am trying to add a Test Project to unit test on of the several projects.

As a proof of concept, I created a HelloWorld project, and a HelloWorldTest project in a different solution. To emulate my larger project, I changed the Configuration Type from .exe to .dll and ran into some errors. But these errors were resolved exporting classes/functions using __declspec(dllexport) along with including .lib in the project, and I am able to build and run the exe of the HelloWorldTest project.

I am trying to follow the same approach for my larger project by painstakingly adding EXPORT statements before classes/functions. However, I run into errors when I include required header files in the Test Project since the header file has other include statements which the Test Project does not understand about. For example, if I include "..\larger_project\custom_math.h" but custom_math.h has something like include "..\..\algo\somefile.h". (I've seen posts about referencing one project to another and have already done the same for my project.)

  1. How do I resolve the issue of chained header file includes? I believe if I can resolve this, I should be able to create objects and start testing in my Test Project.
  2. is there a better way to do this than adding EXPORT statements before every class/function?
273K
  • 29,503
  • 10
  • 41
  • 64
Ashwin Kannan
  • 91
  • 1
  • 11

0 Answers0