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.
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).
To learn how to perform unit testing with TestComplete, see TestComplete Unit Tests.
In TestComplete, you can also call unit tests created by using various unit testing tools. Use Selenium or Unit Testing collections in your test project to manage unit tests created by using the following tools and unit testing frameworks:
You integrate unit tests to your test project, configure them and run them as part of your automated testing process. To learn how to integrate unit tests created by using third-party unit testing frameworks, see Integration With Unit Testing Frameworks.