Calling Routines Declared in Another Project

Applies to TestComplete 15.30, last modified on January 19, 2022

In TestComplete, if you have several projects, you may want to use routines defined in one project in other projects. The uses, import, or USEUNIT clause lets you refer to routines defined in the same project only. To call routines defined in another project, add the unit holding these routines to your project:

Both projects, the source project and the target project, must use the same scripting language. You select the language when you create the project.

  1. Open the target project to which you want to add routines.

  2. In the Project Explorer, right-click the project’s Script item and then click Add > Existing Item.

  3. In the resulting Open File dialog, locate the script unit file that contains the routines you want to add and click Open.

    The script unit file extension depends on the language that the project uses:

    • .js - A JavaScript unit file.

    • .sj - A JScript unit file.

    • .py - A Python unit file.

    • .svb - A VBScript unit file.

    • .sd - A DelphiScript unit file.

    • .scs - A C#Script unit file.

    • .scpp - A C++Script unit file.

    Adding units from another project

    Click the image to enlarge it.

  4. TestComplete will not copy the selected unit file but add a reference to it to the target project. In the Project Explorer, the unit will be marked with the icon.

  5. To call routines declared in the added unit, import them to your target unit. How you do it depends on the scripting language that your project uses, see Calling Routines and Variables Declared in Another Unit.

Tip: To export only several routines that the source unit contains, you can:

  1. In the source project, create a new unit and copy all needed routines to this unit.

  2. Add a reference to the created unit to your target project as described above.

You may even create a ”library“ of units containing all units you want to share among projects.

See Also

Calling Routines and Variables Declared in Another Unit from GUI

Highlight search results