User Defined Function Libraries in Testing

If there is a portion of a code that we need to use several times in the test, then we can create a user-defined function. Using user defined functions, our test become shorter, less complex and easy to design, read and maintain. We can then call these user-defined functions from an action by inserting the relevant keywords into that action.

test-settings.JPG

We can store and define the user-defined functions either directly in an action within a test or in a function library (by default they are saved as a .qfl file). When we store a function in a function library and associate the function library with a test, the test  is able to call the public functions in that function library.

associate-function-libnraries.JPG

If we store a function in a test action, we can use that function only from that action or we can say that the function cannot be called from any other action. This is useful if you do not want the function to be available outside in that function library.

Managing Function Libraries

A Function library is a separate QuickTest document containing VBscript modules, functions and subroutines. Each library opens in a separate window, enabling you to open and work on one or several function libraries at the same time.

function-library-file.jpg

How to create a Function Library

Click the New button down arrow and select Function Library or Select File > New > Function Library. The new function library opens. Now you can add the script to your function and save it. When you add content to your function library, QuickTest applies the same formatting it applies to content in the Expert View. If needed, we can also modify the formatting.

test-settings-window.JPG


Similar Articles