Information in this topic applies to desktop applications only. |
This topic explains how you can create and organize the unit tests of your unmanaged Visual C++ 7.x - 12.0 applications using TestComplete.
Requirements
-
You must have a license for TestComplete Desktop module and the module’s plugins must be enabled in TestComplete.
-
Your application must be compiled as Open with debug information.
-
You must make your test methods as object methods. Non-class routines cannot be called from TestComplete. You can create one or more classes that will contain the testing routines.
Preparing Application for Unit Testing
To make test routines available to TestComplete:
-
Add testing methods to any class in your application. Remember that these methods must not use parameters, because there is no way to supply input values for them.
-
Compile your application as Open. For instructions on how to do this, see Preparing Visual C++ Applications for Testing.
Calling Test Methods From TestComplete
After you compile your application, you can call test routines from TestComplete:
-
Launch your Visual C++ application.
-
In TestComplete, open your test project and add a TCUnitTest item to the project.
-
Open the added test item in the TCUnitTest editor.
-
In the Process text box, click the ellipsis button and select the process started by your application in the subsequent dialog.
-
In the editor, specify the needed tests. To load all tests defined in the application, click Load. To add tests manually, click Add Test and enter the test routine name on the Tests lists. If needed, unite tests into groups.
-
Choose the test run mode:
- Automatically load a list of tests and run all tests - Select this option to run all tests defined in the specified application.
- Run selected tests only - Select this option to specify the list of test routines to be run.
- Automatically load a list of tests and run without selected tests - Select this option to run all tests defined in the application except for the tests selected on the Tests list.
-
Once you configure the test in your project, run it.
During the test run, TestComplete considers a test to pass if there are no exceptions during the test routine run. If a tested routine raises an exception, TestComplete will consider the test to fail and will post an error message to the test log.
Samples
TestComplete includes a sample application that demonstrates unit testing Visual C++ applications:
<TestComplete Samples>\Desktop\Unit Testing\MSVC
TestComplete project suite:
<TestComplete Samples>\Desktop\Unit Testing\MSVC\TCProject
Note: | If you do not have the sample, download the TestComplete Samples installation package from the support.smartbear.com/downloads/testcomplete/samples/ page of our website and run it. |