Software Testing

QTP Best coding practices

Listed below are few coding practices which need to be followed during coding in QTP and VBscript, this is learned from our experience and mistakes. It would be helpful in following these points.

1) Variables should be declared in .vbs file than in action, this will save resources since in action for every iteration the variables will be declared and in .vbs file it is niot the case.

2) Using with statement will reduce script execution time.

3) It is always better to use Option Explicit.

4) To concatenate strings use an ampersand (&) instead of ‘+’.

5) Set the objects to nothing for cleaning the memory.

6) When using array use dynamic arrays (Redim Preserve).

7) It is advisable to declare only one variable in a line.

8) It is better if there is not be more than 80 characters per line.

9) The code should be properly indented.

10) Variables should be declare using appropriate data types.

11) Avoid using the variant data type.

12) Using procedures instead of functions if there is no return value.

13) Closing QTP once in a while will reduce memory leakage.


Please add to this list when ever you get a chance or learn somthing intresting.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s