How to Create, Rename and Delete Classes

Applies to TestComplete 15.64, last modified on May 16, 2024

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

To create a new class

  1. Right-click the ODT | Classes item in the ODT editor or the Classes item in the Classes editor.
  2. Select New Item from the context menu.
  3. TestComplete will create a new class and give it a simple name, e.g. NewClass1. You can then rename the class as you wish.
Names of classes are used for referring to classes in scripts and keyword tests. That is why these names must consist of the A..Z, a..z, 0..9 and _ characters only (that is, they must be valid identifiers in the scripting language you use). The class names are case-sensitive in JScript, C++Script and C#Script scripts, and case-insensitive in VBScript and DelphiScript scripts.
Note: The name OleObject is reserved. You cannot create classes with this name.

Creation of a new class is an analogue of declaring a class in programming. It does not create an instance of this class. To create a class instance, you need to create a new object.

To rename a class

  1. In the ODT or Classes editor, right-click the class that you want to rename and select Rename from the context menu, or choose the desired class in the tree view and press F2. TestComplete will activate an in-place editor.
  2. Enter the desired name for the class.
  3. To apply changes, press Enter or click somewhere outside of the in-place editor. To cancel changes, press Esc.

To copy and paste a class

You can copy and paste class declarations within a project or between different projects. The names and values of class properties and methods are preserved.

To copy a class declaration to the clipboard:

  • Right-click the desired class name in the ODT or Classes editor and choose Copy from the context menu.

To paste a class declaration from the clipboard:

  1. Select the position in the editor, where you want the new class to be located. A class can only be pasted to the same hierarchy level from which it was copied.
  2. Click the right mouse button and select Paste from the context menu.
Note: When copying a class from one project to another, the names of script routines for class methods are copied without any changes. Thus, it is very likely that a new project would not contain the routines with the specified names. Therefore, you should redefine method handling routines in order to utilize the new class.

To change the class position

By default the classes names are shown in the same order that they were created in. However, you can rearrange them in whatever order you like. To do this:

  • Right-click the desired class name in the editor and choose Move Up or Move Down from the context menu to move the class in the corresponding direction.

To delete a class

  1. In the ODT or Classes editor, right-click the class you want to delete and select Delete from the context menu.
  2. TestComplete will display a message box asking you if you want to delete the selected class. Click OK to delete the class, or Cancel to cancel the deletion.
Note: When you delete a class, all objects that are based on this class are also deleted.

See Also

Object-Driven Testing
ODT Editor
Classes Editor
How to Create, Rename and Delete Data Groups
How to Create, Modify and Delete Properties
How to Create, Modify and Delete Methods

Highlight search results