How to configure Visual Studio CppUnitTest

37 views Asked by At

I am new to using VS Unit Testing. I have a simple solution of a c program that creates a .exe executable. The test program is using the CppUnitTestFramework. The directory Structure has both the HelloWorld application to test and the UnitTest1 Test application in the default Repos directory.
|Repos |HelloWorld //source files are in this directory |Debug //object files are here |UnitTest1 // source files of test program are here |Debug // object files are here The HelloWorld has a main.c which calls single function AddIntegers which is located in file TestFunctions.c, when it is built its creates TestFunction.obj and the executable runs correctly.

I followed the directions in https://learn.microsoft.com/en-us/visualstudio/test/how-to-use-microsoft-test-framework-for-cpp?view=vs-2022#separate_project to link object files to the tests.

I added TestFunctions.obj;%(AdditionalDependencies) to the test program properties for linker->Input->AdditionalDependencies

I added ..\HelloWorld\Debug to the test program properties for linker->General->Additional Library Directories.

When I try to use the AddInteger function in my test program I get a linker error "UnitTest1.obj : error LNK2019: unresolved external symbol "short __cdecl AddIntegers(short,short)"

Can someone tell me what I am missing?

I have tried multiple changes to the library paths but to no avail.

0

There are 0 answers