Link to classes from the VC ++. EXE project from unit tests .EXE project

I have an old deprecated C ++ application that I am trying to write for some unit tests. I created a second project in my solution, which is based on unit testing the executable file (using googletest). The test project refers to the header files from the main project. The test project builds until I try to use one of the classes from the main project.

#include "stdafx.h"

#include "JsContext.h"
#include "gtest/gtest.h"

TEST(JsContextTests, CreateJsContext) {
  JsContext context; // linking fails as soon as this line is added
}

It gives ..

Error   1   error LNK2001: unresolved external symbol "public: __thiscall JsContext::JsContext(void)" (??0JsContext@@QAE@XZ)    JsContextTests.obj  tests
Error   2   fatal error LNK1120: 1 unresolved externals D:\Projects\Js-Clean\src\Debug\tests.exe    tests

The main executable does not create a .lib file, so I'm not sure what I should link the test project with.

What is the best approach to unit testing classes from another exe project?

+5
source share
1 answer

, .obj, JsContext.cpp, , JsContext.h. , , . → → .

, , , , , ; "Main Project Dependencies" , .

, , , .obj , .

+6

All Articles