Already reviewed all the instructions. To the Solution with the project that I am going to test, I added a test project with the tests themselves. Already and Source Directory pointed out and link pointed to the main project. And I cannot turn to classes. Tell me something.

IDE - VS 2015

  • Indicate the development environment - Cerbo
  • It is necessary to collect google test, then, in your project to connect the collected libraries. What is it that you can't do? - ixSci
  • So I did, I connected gtest.lib to the test project. I start to write a test, but I don’t get involved with the leaders of the tested project. I clarify: test and test project - different projects. Test - in which connected gtest.lib. - Sergey
  • Those. In the test project, google test headers are visible, are the headers of the project you want to test not visible? - ixSci
  • Yes exactly. - Sergey

1 answer 1

You need to go to the project settings with tests and in VC++ Directories , in the field Include Directories add the directory with the headers you need. It will look something like this: ../ProjectToTest/Headers - it is better to set a relative path, otherwise everything will break if moved to another place.

But you need to understand that the headlines are not the only problem; if the project that you want to test has cpp files, then it should be the library that you connect to the test project. Otherwise, connecting the headers will cause you to get a linker error.

And a link to MSDN where you can learn how to add a link to a neighboring project so that the lib automatically used by the current project: Adding references in Visual C ++ projects

  • I apologize and thank you. Is it possible to build a library from an already finished project, if I didn’t specify during creation that it would be a dll? - Sergey
  • @ Sergey, in the settings of the project, in the General/Project Defaults you can change the Configuration type - ixSci
  • Thanks, I will try. - Sergey