Friday, July 17, 2009

Working with Associated Function Libraries

In QuickTest, you can create function libraries containing functions, subroutines, modules, and so forth, and then associate the files with your test. This enables you to insert a call to a public function or subroutine in the associated function library from that test. (Public functions stored in function libraries can be called from any associated test, whereas private functions can be called only from within the same function library.)

If a test can no longer access a function that was used in a step (for example, if the function was deleted from the associated function library), the icon is displayed adjacent to the step in the Keyword View. When you run the test, an error will occur when it reaches the step using the nonexistent function.

Note: Any text file written in standard VBScript syntax can be used as a function library.

You can specify the default function libraries for all new tests in the Test Settings dialog box (File > Settings > Resources tab). After a test is created, the list of default function libraries is integrated into the test. Therefore any changes to the default function libraries list in the Test Settings dialog box do not affect existing tests.

You can edit the list of associated function libraries for an existing test in the Test Settings dialog box. For more information, see Defining Resource Settings for Your Test.


In addition to the functions available in the associated function libraries, you can also call a function contained in any function library (or VBscript file) directly from any action using the ExecuteFile function. You can also insert ExecuteFile statements within an associated function library. For more information, see Executing Externally-Defined Functions from Your Test.
You cannot debug a file that is called using an ExecuteFile statement, or any of the functions contained in the file. In addition, when debugging a test that contains an ExecuteFile statement, the execution marker may not be correctly displayed

Library files in QTP are used to declare functions that are needed to be used across actions

A Library File included on the Resource tab are placed in the test’s Global namespace at runtime, and are therefore shared and accessible by all Actions included in the test.

Including a library in a test Action, using the ExecuteFile(“libname”) QTP statement. Libraries included in this manner are placed in the including Action’s namespace, and therefore may only be used by the including Action’s code.

It is also possible to use one or more ExecuteFile(“libname”) statements within a library included via the Test Settings Resource tab as well. In this scenario all library files are placed in the test’s Global namespace.

And also a library file can be included from External VBA file directly by using QTA APPLICATION object.

No comments:

Post a Comment