

The path is typically within the build folder of the project under test. Select the Configuration Properties > Linker > General page, then select Additional Library Directories.Ĭhoose Edit, and add the directory path of the. Select the Configuration Properties > Linker > Input page, then select Additional Dependencies.Ĭhoose Edit, and add the names of the. In Solution Explorer, on the shortcut menu of the test project, choose Properties.

Modify the test project's properties to include the headers and library or object files that are required for unit testing. lib file to the dependencies of the test project. If the code under test doesn't export the functions that you want to test, you can add the output. To link the tests to the object or library files In the Add New Item dialog, select C++ File (.cpp), give it an appropriate name, and then choose Add. Right-click on the project node in Solution Explorer and choose Add > New Item. $(VCInstallDir)Auxiliary\VS\UnitTest\include Select the down arrow in the following rows and choose. In the Property Pages dialog, select Configuration Properties > VC++ Directories. In Solution Explorer, on the shortcut menu of the project you're testing, choose Properties. Modify the project properties to include the headers and library files that are required for unit testing.

In some cases, for example when testing non-exported functions in a DLL, you might need to create the tests in the same project as the program you're testing. To set up and configure a new test project, see Writing unit tests for C/C++. Typically, you run your test code in its own project in the same solution as the code you want to test. To write unit tests in a separate project The Microsoft Unit Testing Framework for C++ is included by default in the Desktop Development with C++ workload. Use the Microsoft Unit Testing Framework for C++ in Visual Studio
