Creating a C/C++ Unit Test
See Also
The C/C++ Unit test feature enables you to create test programs for use as
templates for your unit tests. You can create unit tests for single functions and entire
source files, as well as empty test files to be used with sources you create later.
The IDE creates a Test Files logical folder when you create a project. For managed
projects that were created with a previous version of the IDE, a Test Files folder
is created when you add tests through the IDE. In both cases, the test files are
physically stored in a tests directory, separate from the project's source files.
For projects from existing sources:
To create a test for a single source file:
-
Right-click the file in the Projects window or in the editor window and choose Create Tests > New test type
to open the Tests wizard.
-
Select the functions you want to test and click Next.
- Type the name of the test and the filename of the test source.
- Click Finish.
- Edit the test source file for your project.
To create an empty test:
-
Choose File > New File from the main menu.
-
In the New File wizard, select C/C++ Tests in the Categories pane and the type of unit
test you want in the File Types pane. Click Next.
-
Specify the test name, folder, and test source filename and extension.
-
Click Finish.
-
See Also
-
Running a C/C++ Unit Test
-
About C/C++ Unit Tests
Legal Notices