Tuesday 18 March 2014

Actions vs Functions in QTP

There are few pros and cons in both approaches but I prefer functions over actions.
Some key points when using Actions are:

·    Action parameters can’t accept complex values like arrays or object.
·          Actions allow us to have optional parameters.
·         A blank Action with no object and no code occupies 150+KB of spaces, so using too many Actions increases the size of scripts.
·         Re-usable Actions, when called in test are read only. So if, there is an issue in running the test and the Action’s code need to be updated for fixing it, we would need to close the test and re-open it containing the re-usable action. After making changes to the Action code we need to open the test again for execution and in case it fails we must repeat the procedure for fixing the code.
·         Actions create a separate section in the test results summary making it easier to differentiate functionality.
      Compared to Actions, Functions have few advantages:
·         Functions don’t take much space since they don’t have associated Local OR or DataTable.
·         Functions can be edited easily as compared to external actions. This make maintenance much easier.
·         Functions parameters can take any possible value supported by VB Script.
·         Functions can easily be overridden by redefining them.
So, I prefer Functions because maintenance becomes huge when we have too many Actions.

No comments:

Post a Comment