TestComplete Unit Tests - Visual C++ Applications

Applies to TestComplete 15.47, last modified on January 20, 2023
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:

  1. Launch your Visual C++ application.

  2. In TestComplete, open your test project and add a TCUnitTest item to the project.

  3. Open the added test item in the TCUnitTest editor.

  4. In the Process text box, click the ellipsis button and select the process started by your application in the subsequent dialog.

    Specify the tested project
  5. 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.

    TCUnit Test item settings
  6. 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.
  7. 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/testcomplete/downloads/samples page of our website and run it.

See Also

TestComplete Unit Tests - Overview

Highlight search results