Object-Driven Testing - Basic Concepts

Applies to TestComplete 14.71, last modified on April 22, 2021

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.

Often, creation of scripts is mainly a programming task. If a test does not require loads of data and it is aimed at testing one object only (for instance, one application form), then you can write one or two script routines that use several local variables and, perhaps, some global constants. However, most test projects are large, they include lots of script routines and use a lot of testing data. In this case, programming becomes logically simpler if you do it in an object-oriented way, that is, if you use custom objects. For instance, you may create an individual object for each tested form and then use methods and properties of this object to test the controls on the form.

Sometimes, you need to not only create individual objects, but a complex object hierarchy, where object properties hold custom data structures, arrays, references to other objects, etc. In order to support the custom objects capability, TestComplete uses the Object-Driven Testing (ODT) project item.

The ODT project item allows you to create ordinary data variables (integers, strings, dates, etc.) as well as custom objects and multi-dimensional arrays. Each array element can store an ordinary value, an object or it can be an array itself. Similarly, each object property can store an ordinary value, an array or can refer to another object. That is, using this project item you can create an object hierarchy of any complexity.

You can visually create custom data structures and objects for your tests. The programming objects allow you to perform the same operations from scripts or keyword tests, using the ODT object. In other words, you can create custom data both visually and programmatically. You can also combine the techniques: you can declare classes visually and create instances of these classes in scripts or keyword tests at run time.

The ODT project item works with custom data structures and objects using the following principles:

  • Data is organized into groups. Each group holds a collection of variables. Every variable can store an ordinary value, an array or an object. To configure data, use the Data sub-item of the ODT project item. To create and access custom data from scripts or keyword tests, use methods and properties of the Data object.
  • All custom objects must be created on the base of a class that was created via the Classes sub-item of the ODT project item or using the methods and properties of the Classes object. That is, before you create an object, you must create a class for it.

    Note: The class concept provided by the project item differs from the class concept in programming languages such as C++ or Object Pascal. The difference is that an object can contain its “personal” methods and properties in addition to those that are declared in the object's class. The “personal” methods and properties of the object are not available to other objects based on the same class.

    In addition, an object you create via the ODT project item can only be referred to by one object property, array item or a data-group variable. That is, two or more properties, array items or data-group variables referring to the same object at the same moment in time is not allowed. An object can only be referred by one property. See Working With Custom Objects in Scripts.

    If you add a method or property to a class, it is also added to all objects that are based on this class. When you delete a method or property from a class, it is also deleted from objects based on this class.

    If a class property holds an array and you add a new item to this array, the new item is inserted into the appropriate position in all “object” arrays. When you delete an item from a “class” array, this item is also deleted from the “object” arrays.

  • An object method is a script routine. It differs from other script routines in that it has access to the object properties. Generally, this reduces the number of parameters a routine would have if you did not use classes.
  • To refer to the object instance to which a method belongs use the keyword Self in DelphiScript or This in VBScript, JScript, C++Script or C#Script (note the first capital). For more information, see Working With Custom Objects in Scripts.
  • In JScript, C++Script and C#Script projects, the arrays that were created with the Object-Driven Testing technique are not compatible with arrays that were created by scripting language routines. To access the items of the “plugin” arrays, use methods and properties of the ArrayType and ArrayObject program objects. These objects are provided by the ODT project item. In fact, the project item also employs them in DelphiScript and VBScript projects, but it uses them implicitly.

The ODT project item defines one object-driven test in the given project. You can run this test individually, as a test item, or initiate its execution from an ordinary script or from a keyword test (using the Run Test operation).

See Also

Object-Driven Testing

Highlight search results