1

I would like to use GoogleTest to run unit tests on my project. In my solution I have three projects:

The GoogleTest project, which is a static library My Project Under Test, an executable My Project containing my Unit Tests, an executable

enter image description here

My Tests run fine, but only if I manually include the .h & .cpp files from my project under test into my Unit Tests project. I'd like to avoid this step, is there some what to do this? Please if I'm neglecting to mention any important details just let me know.

The Error I receive if I don't manually include these files is: enter image description here

  • Can you explain why you added GoogleTest to your solution and not add just build GoogleTest outside of the project and then just add path to gtest/include and gtest/lib to your UnitTest_TestProject1? – theateist Jul 27 '18 at 5:33
1

From error, I can see it is a linking error. You need to add reference of static gtest library in your main project.

Make sure you have added

  • Include path to gtest and gtest/inlcude
  • Added linked include path for .lib
  • Added lib name in linker input

Installing and Using GoogleTest with Visual Studio

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.