Monday, March 23, 2009

Actions Vs Functions

Actually I found this data from another blog...  I know the difference between Actions and Functions but, this contain somemore information about Actions and Functions. 

Actions vs Functions in QTP 9.0

When deciding whether a piece of code should go in a reusable Action or a Function, we usually favored functions in QTP 8.2. When Mercury introduced QuickTest 9.0, they made the argument for functions even more compelling with the Multi Document Interface. Now we can open as many function libraries as we want, but we are still limited to one test. So, if you want to edit a reusable action in another test, you have to close your current test, open the second test, make your changes, save and close the second test then reopen your original test.

In addition to that new argument for functions in QTP 9.0, the same old arguments from 8.2 still apply. I’ll sum up a few of the key differences between reusable actions and functions here.

Passing Data

Actions - can only accept primitive data types as parameters (strings, integers, etc)

Functions - can accept arrays, dictionary objects and test objects (i.e. Pages, Frames, WebRadioGroups, etc.)

Resource Usage

Actions - For each action, there’s a folder, three separate vbs files, a local Object Repository, a subfolder containing snapshots, an Excel spreadsheet, and a few seconds of load time. 

Functions - There’s the code contained in the Function, and that’s all 


Actions - You cannot insert calls to Existing Actions through the QTP API, you can only do it through the interface

Functions - You can attach Function Libraries to Test Scripts through the QTP API 

Return Values

Actions - Return values are difficult to understand and read in the syntax 

Functions - Return values work like they do in other languages (i.e. as lvalues) 

You cannot change the number of parameters that a function accepts without affecting all calls to that function. That is a problem that used to drive me crazy. It seems like every time I put a new function in a library, the next test I write needs that function with one extra option. Now that I use the getopts function to define the parameters in my functions, I can easily add new optional parameters without messing up other tests that already call the function. 

Thanks & Regards

Baba Fakruddin.D

No comments: