Known Issues- Function Libraries and user-defined functions

Relevant for: GUI tests and components

Defining a VBScript class in a function

If you define a VBScript class, it can be called only within the UFT action or function library in which you defined it.

Workaround:

  1. You can use an ExecuteFile statement to call a VBScript class defined in an external function library.

  2. In the function library in which you define the class, create a function that sets an object as your class, and returns the object. Then you can call this function from anywhere in your test or component, to assign an object of your class to a variable you define.

    Example:  

    Suppose you want to use the class myClass. In the same function library as you define myClass, define the following function:

    public function myClassGenerator()
    set myClassGenerator = new myClass
    end function

    Now, you can use the myClass class by calling myClassGenerator, like this:

    set myClassObject = myClassGenerator()

    myClassGenerator() creates a new myClass object and assigns it to myClassObject.

Calling a test object method that has been overwritten by a fuction

You can use the RegisterUserFunc statement to register a user-defined function that overrides an existing test object method. You can also register a user-defined function to override a test object method that was created using a UFT Extensibility SDK. If you override this type of test object method, the user-defined function must not (recursively) call the test object method that it overrides.

User-defined functions in the run results

By default, steps that use user-defined functions are not included in the run results after a run session. If you want the function to appear in the run results, you must add a ReportEvent Method statement to the function code. For example, you may want to provide additional information or to modify the test, component, or business process test status.

If a step within your user-defined function calls a standard UFT test object method, this step will appear in the run results after the run session. However, you can still add a Reporter.ReportEvent statement to the function code to provide additional information and to modify the test, component, or business process test status, if required.

Partial test runs and method registration

For tests: If you use a partial run or debug option, such as Run from step or Debug from step, to begin running a test from a point after method registration was performed in a test step (and not in a function library), UFT does not recognize the method registration because it occurred prior to the beginning of the current run session.

Using the Option Explicit method

To use an Option Explicit statement in a function library associated with your test or component, you must include it in all of the function libraries associated with the test or component. If you include an Option Explicit statement in only some of the associated function libraries, UFT ignores all of the Option Explicit statements in all function libraries.

In test actions, you can use Option Explicit statements directly without any restrictions.

Unique variables in function libraries

Each function library must have unique variables in its global scope. If you have two associated function libraries that define the same variable in the global scope using a Dim statement or define two constants with the same name, the second definition causes a syntax error. If you need to use more than one variable with the same name in the global scope, include a Dim statement only in the last function library (since function libraries are loaded in the reverse order).

Class definitions in a function library

Function libraries that run in the same run session must not contain different definitions for the same class. Make sure that each class is defined in only one location.

Modifying function libraries

If another user modifies a function library that is referenced by a test or component, or if you modify the function library using an external editor (not UFT), the changes take effect only after the test or component is reopened.

Cyrillic characters in function libraries

Function libraries that contain the Cyrillic ' ' character and are saved in ANSI encoding may be interpreted incorrectly in UFT. For example, the ' ' character may be interpreted as a newline character, causing the run to fail.

Workaround: If this problem occurs, use a text editor to convert the function library by saving it in Unicode encoding.