TestComplete Unit Tests - C++Builder Applications

Applies to TestComplete 12.60, last modified on September 17, 2018
Information in this topic applies to desktop applications only.

This topic describes how you can create and organize the unit tests of your C++Builder applications by using TestComplete.

Requirements

  • You must have a license for TestComplete Desktop module.

  • Your C++Builder application must be compiled as an Open with debug information.

  • You must make your test methods as object methods. This corresponds to the unit test structure, in which one testing class tests one or several objects in the application under test. You can create one or more classes that will contain the testing routines.

Preparing Application for Unit Testing

Create testing classes and make them available for TestComplete:

  1. Create test classes in your application.

    Note that test routines you are going to call from TestComplete must not use parameters. There is no way to supply input values for test routines from TestComplete.

  2. Use one of the following approaches to make sure that C++Builder’s smart linker does not exclude your test routines from the application code:

    • Make your routine published. The linker does not exclude published elements, so they are always present in the application’s code.

    • Make your routine virtual. The linker does not exclude virtual methods.

    • Call your routine somewhere in your code.

  3. Compile your application as Open. For detailed instructions on how to do this in various C++Builder versions, see the following topics:

    Compiling C++Builder XE2 – XE8 and 10 Applications With Debug Information

    Compiling C++Builder XE Applications With Debug Information

    Compiling C++Builder 2010 Applications With Debug Information

    Compiling C++Builder 2009 Applications With Debug Information

    Compiling C++Builder 2007 Applications With Debug Information

    Compiling C++Builder 2006 Applications With Debug Information

    Compiling C++Builder 6 Applications With Debug Information

Calling Test Methods From TestComplete

After you compile your application, you can call test routines from TestComplete:

  1. Launch your C++Builder application.

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

  3. Open the added 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 a list of test routines to 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, run it.

Note: When TestComplete runs a unit test, first, it creates a new instance of the testing class that holds the testing routine, and then calls the routine. TestComplete does not use existent instances of testing classes. It always creates new instances.

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.

See Also

TestComplete Unit Tests - Overview
Unit Testing Samples

Highlight search results