TestComplete Unit Tests - Overview

Applies to TestComplete 15.63, last modified on April 10, 2024

Unit testing is testing of procedures or methods that a source module makes available to the rest of an application. A “unit” can be anything from a single procedure to an entire library. The essential point of unit testing is that you test only a small part of the application.

In TestComplete, you can create unit tests by accessing and calling internal methods of applications. You can also run unit tests created by using third-party unit testing frameworks and tools.

This section describes how to create unit tests in TestComplete.

To learn how to run unit tests created with third-party unit testing frameworks, see Integration With Unit Testing Frameworks.

Testing Units in TestComplete

The easiest way to test a unit is to write a small application, called a “driver” or “test harness”, that runs tested procedures and reports the results. The test harness must have the same level of access to the unit programming interface (for example, header in C++, Interface part in Delphi) as the other units in the final application.

Units often take external input (for instance, through a dialog), or they have external output (for instance, file updates), which you also may need to test.

TestComplete can access to internal objects, methods and properties of the application under test (the application must be compiled as Open). This way you can put the test harness methods in TestComplete scripts, or in the tested application itself. The latter is more common, since it gives the test harness deeper access to the needed application internals.

Another way to create unit tests is to place the unit test driver to a Connected Application. A unit test driver compiled as a Connected Application can call the TestComplete engine and supply the pre-recorded input, or input coded directly in the driver. It can also gather any form of output and compare the output with baseline data. Most important, the connected driver can use the engine to post its results to the TestComplete project log, so they remain part of the entire test project.

Connected and self-testing applications are deprecated. We do not recommend using them.

That is, in TestComplete, you can –

  • Run the unit test harness.

  • Gather the results which the harness reports.

  • Feed the needed input to the tested unit.

  • Get the unit’s output. Return it to the harness for comparison, or compare it directly (preferred, because the test tool is “foreign” to the code that generated the output).

See Also

Testing Approaches
Different Ways of Testing

Highlight search results