0% found this document useful (0 votes)
29 views3 pages

Function Definition Generator

The document describes how to create reusable functions in QuickTest Professional (QTP) tests using the Function Definition Generator. Functions can be created manually or using the generator. The generator allows defining functions by specifying their name and arguments, and then generates the function template to be filled in. It provides an easier way to create functions than manually writing them out. Functions make tests more modular, reusable, readable and maintainable.

Uploaded by

deepandeva
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Function Definition Generator

The document describes how to create reusable functions in QuickTest Professional (QTP) tests using the Function Definition Generator. Functions can be created manually or using the generator. The generator allows defining functions by specifying their name and arguments, and then generates the function template to be filled in. It provides an easier way to create functions than manually writing them out. Functions make tests more modular, reusable, readable and maintainable.

Uploaded by

deepandeva
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Function definition Generator

If you have repeatable steps in a test or an action then consider using a user defined function. User defined functions will make your tests look shorter, easier to maintain, read and design. Advantages of Function Library (functions) 1. Time and resources can be saved by implementing and using user defined reusable functions. 2. User defined functions can be stored in a function library or within an action in the test. 3. User defined functions can be registered as a method for a QTP test object If the function is stored in a function library then we have to associate that function library to a test. So that the test can call all the public functions listed in that library. Functions can be created manually or by using Function Definition Generator. It is easy to create a function library (Manual): Steps:
1.

Open a new function library(FileNewFunction library)

2. Add content to it(That is we have to write body of the function here) 3. Open a new test
4.

Associate the function library with a new test (File Associate library with Test).

5. Now run the test.

Creating the function Library through Function definition generator: Steps: 1. Open a new test.
2.

Open a new function library. Go to New Function library. (Now both new test and function library are open at the same time and we are in function library)

3.

Go to Insert Function Definition Generator.

4. In the Function Definition Generator window, type the name of the function as add. 5. In the Arguments area Click on + and type the name of first argument as a and again click on + and type the name of second argument as b and let the pass mode be the default which is By Value. 6. Click on OK to close that Function Definition Generator window.
7.

Now it will add the function to your already open library.

8. Now we have to write the function body(where it says TODO: ) as the following Public Function add (a, b) Sum = a+b

Msgbox Sum End Function 9. Save it (Save it by giving any name and extension either .qfl (by default) or .vbs or .txt)
10. Associate

it (File Associate Library With test)

11.

Now in the Expert view of the test type:

add 25,25 (i.e., the values for a and b) 12. Run the Test

You might also like