Testing Delphi Applications - Overview

Applies to TestComplete 15.47, last modified on January 20, 2023

This topic provides a brief overview of testing Delphi applications with TestComplete.

General Notes on Delphi Applications Testing

With TestComplete you can easily test your Delphi applications. You can perform any kind of testing – unit, functional, regression and so on. The easiest way to create a test for your application is to record a keyword test or script routine. While replaying a test, TestComplete will repeat all the recorded actions you performed with the tested Delphi application during the recording. If necessary, you can also extend the recorded test manually using a number of specific features provided by TestComplete.

TestComplete supports applications (both VCL and CLX) created with the following versions of the Delphi compiler:

  • Embarcadero Delphi 10 Seattle, Delphi 10.1 Berlin (Update 1 and Update 2), Delphi 10.2 Tokyo, Delphi 10.3 Rio, Delphi 10.4 Sydney, including 64-bit Delphi applications

  • Embarcadero Delphi XE2 – XE8, including 64-bit Delphi applications

  • Embarcadero Delphi 2010 and XE

  • CodeGear Delphi 2007 and 2009

  • Borland Delphi 2005 and 2006

  • Borland Delphi v. 7.0

Note: Delphi for .NET applications are supported and handled as .NET applications.

TestComplete only supports Delphi applications that use VCL and CLX or third-party VCL- and CLX-based controls.

TestComplete does not support Delphi applications built with cross-platform frameworks that render the application interface as graphic (for example, Embarcadero FireMonkey).

As a workaround, to test such applications, you can use one of the following options:

Creating and Recording Tests for Delphi Applications

With TestComplete, you can record and play back user actions in Delphi applications, or you can create tests manually from scratch. Usually, it is easier to record the test first and then modify and enhance the recorded test.

When you record a test, you interact with the tested Delphi application as an end-user would: navigate through the application’s screens, fill out forms and so on. TestComplete captures all actions you perform in the application and adds them to the test.

A test consists of a sequence of operations that define various interactions with objects in the tested application. For example, in the sample test below you can see that item selection from a combo box is represented by the ClickItem operation, text input into text boxes - by the SetText operation, and so on.

A sample keyword test recorded against a Delphi application
A sample keyword test recorded against a Delphi application

JavaScript, JScript

function Test1()
{
  var orderFrm;
  var edit;
  orderFrm = Aliases.Orders.OrderFrm;
  orderFrm.Product_ComboBox.ClickItem("FamilyAlbum");
  edit = orderFrm.CustomerName_Edit;
  edit.Click(12,10);
  edit.SetText("John Smith");
  orderFrm.OKButton.ClickButton();
}

Python

def Test1():
  orderFrm = Aliases.Orders.OrderFrm;
  orderFrm.Product_ComboBox.ClickItem("FamilyAlbum");
  edit = orderFrm.CustomerName_Edit;
  edit.Click(12,10);
  edit.SetText("John Smith");
  orderFrm.OKButton.ClickButton();

VBScript

Sub Test1
  Dim orderFrm
  Dim edit
  Set orderFrm = Aliases.Orders.OrderFrm
  Call orderFrm.Product_ComboBox.ClickItem("FamilyAlbum")
  Set edit = orderFrm.CustomerName_Edit
  Call edit.Click(12,10)
  Call edit.SetText("John Smith")
  orderFrm.OKButton.ClickButton
End Sub

DelphiScript

procedure Test1;
  var orderFrm : OleVariant;
  var edit : OleVariant;
begin
  orderFrm := Aliases.Orders.OrderFrm;
  orderFrm.Product_ComboBox.ClickItem('FamilyAlbum');
  edit := orderFrm.CustomerName_Edit;
  edit.Click(12,10);
  edit.SetText('John Smith');
  orderFrm.OKButton.ClickButton;
end;

C++Script, C#Script

function Test1()
{
  var orderFrm;
  var edit;
  orderFrm = Aliases["Orders"]["OrderFrm"];
  orderFrm["Product_ComboBox"]["ClickItem"]("FamilyAlbum");
  edit = orderFrm["CustomerName_Edit"];
  edit["Click"](12,10);
  edit["SetText"]("John Smith");
  orderFrm["OKButton"]["ClickButton"]();
}

The recorded tests can be modified and enhanced in a number of ways to create more flexible and efficient tests. For example, you can:

  • Add new operations, reorder operations and modify their parameters.

  • Delete or disable unneeded operations (for example, superfluous recorded operations).

  • Insert checkpoints for verifying objects and values in the tested application.

  • Create data-driven tests that run multiple test iterations using different sets of data.

Refer to the following topics to learn more about creating and enhancing tests:

Task See topic…
Creating tests using recording Recording Tests
Creating tests manually Keyword Testing and Scripting
Simulating user actions Working With Application Objects and Controls
Running tests Running Tests
Launching applications automatically at the beginning of the test run Adding Tested Applications and
Running Tested Applications
Creating checkpoints for verifying application behavior and state Checkpoints
Running multiple test iterations using data from an external file Data-Driven Testing

About Test Types

There are two major test formats in TestComplete:

  • Keyword tests - visually configured tests with grid-based editing interface. Best suited for novice users and those without programming knowledge.

  • Scripts - code written in one of the supported scripting languages. May be better suited for advanced users.

You select the test type when creating a test and cannot change it later. However, you can mix keyword tests and scripts within the same test project and call them from each other.

TestComplete also includes additional test types, such as low-level procedures, unit tests, and so on. You can use them to address specific testing needs. However, most automation is typically done using keyword tests and scripts.

About Delphi Object Identification and Name Mapping

Each object in an application has a number of properties, such as its location, text, type and so on. Some object properties are persistent and unchanging, and therefore can be used to locate objects in applications and differentiate among various objects.

When you record a test, TestComplete captures all windows and controls that you interacted with during the recording session and adds them to the Name Mapping project item (also known as the object repository or GUI map). For each captured object, TestComplete does the following:

  • Selects a set of properties and values that uniquely identify the object in the application and saves them to Name Mapping as the object identification criteria. These properties will be used for locating the object during subsequent test recording, editing and run sessions.

  • Generates an alias (name) that will be used to reference this object in tests. By default, TestComplete generates aliases based on object names defined in the application by developers.

  • Automatically captures and adds images of the mapped objects to the Name Mapping repository. This helps you understand which window or control one or another mapped object matches.

The following image shows sample Name Mapping for a Delphi application:

Sample Name Mapping for a Delphi application

Here, the Customer object is identified only by one property - NativeDelphiObject.Name. This property specifies the object name as it is defined by the application developers in the application’s source code. However, Delphi application objects can also be located by other properties, such as their class name, text and so on -- whatever best identifies a specific object.

If needed, you can modify the default Name Mapping generated by TestComplete. For example, you can:

For more information, see Name Mapping.

Keep in mind that the object hierarchy in Name Mapping mirrors the object hierarchy in the tested application. When locating an object, TestComplete takes into account its entire parent hierarchy. If any object in the parent hierarchy cannot be found using the specified property values, the target object cannot be located as well. That is why it is important to select unique and unchanging properties for object identification.

About Support for Delphi Controls

TestComplete recognizes individual controls of Delphi applications and lets you interact with them both at design time and while recording or replaying a test. In addition, it simplifies testing the user interface of your application since it includes a number of specific testing abilities for the most frequently used Delphi controls.

For detailed information on which controls TestComplete provides extended support for and what abilities for testing applications’ controls it enables, see Support for Delphi Applications' Controls.

Using Native Delphi Methods and Properties in Testing

TestComplete makes visual objects of Delphi applications available for testing, that is, you can recognize these objects, interact with them and work with native properties and methods of internal Delphi objects.

By default, TestComplete enables you to access published properties from your tests, that is, you can call these properties from your tests.

If your application is compiled in a special way (with debug information included), TestComplete provides you with access to the application’s public, protected and private members. For detailed information on how to compile Delphi applications with debug information, see the Preparing Delphi Applications for Testing section.

Note: Note that, some native properties and methods of Delphi objects are unavailable to TestComplete. For more information, see Object Properties, Fields and Methods That Are Unavailable to TestComplete.

For detailed information on how to address exposed properties and methods from your tests, see Accessing Native Properties and Methods of Delphi Objects and Addressing Objects in Delphi Applications.

Viewing Object Properties and Methods

To see what operations (methods) are available for objects in your tested Delphi application, as well as the object properties and their values, you can use the Object Browser or Object Spy. Available properties and methods include those provided by TestComplete, as well as native object properties and methods defined by the developers in the application’s source code.

You can view object properties and methods both at design time and at run time when the test is paused.

For more information on using the Object Browser, see Object Browser and Exploring Applications.

Samples

TestComplete includes sample Delphi application and a number of corresponding test projects:

<TestComplete Samples>\Desktop\Orders\Delphi

Note: If you do not have the samples, download the TestComplete Samples installation package from the support.smartbear.com/testcomplete/downloads/samples page of our website and run it.

Where to Go Next

For further information about automating tests with TestComplete, refer to the following sections:

See Also

Supported Development Tools

Highlight search results