Association of Library Functions and Object Repositories
Some places, I've seen people associate library functions and Object Repositories via the QTP/UFT GUI.
Others do this association via Initialization Settings file (usually .vbs).
What do you use for this file associaton?
Advantages / disadvantages of using one versus the other that you know of?
I prefer to associate from the test (in UFT/QTP) as this creates links that ALM/QC can also see and present in the form of dependency mapping.
The advantage of using a file is that you don't have to mess about with a slow UI.
... just another Tester ...
The frameworks I've used in the past load them on demand dynamically. i.e. if your test step(as defined in QC/Excel/whatever) calls for the login page it would load the login object repository and function library. Much more efficient to do it that way. Cut down test load and execution time vs using actions and having ORs always loaded.
Wow! Your way/method sounds very interesting. If it is okay, do you mind sharing more info or samples on how this is done?
Also, does your method work well when scripts are run via QC/ALM?
Last edited by Gilbert; 12-05-2014 at 07:19 AM.
Reason: added more info
Yeah, you use 'RepositoriesCollection.Add' to add a repository at run time and 'execute' to load a function library into memory.
Just had a one line call to a driver for the test in QC that passed in the test name/id/run info to a framework processor. From that used the QC api to retrieve the test steps and called params which were translated into procedures to call. Posted results to QC and everything just as if it was a native test.
You won't get autocomplete in the ide when loading things dynamically. So when creating/editing you can temporarily associate it for that if you want it.
Last edited by NoUse4aName; 12-05-2014 at 07:50 AM.
So you must have multiple ORs then? One for Login OR, etc.
In your example, you added/loaded the login repository then once login is completed, you do a Remove or Delete and then when other test cases require you to login, you Add and Remove this repository again and again?
Here at work, we basically have one OR (almost per Project/Application).
So we load the repositories from InitializationSettings.vbs like:
strRepositoryPath = Environment.Value("Path1") & "Sample1.tsr"
Set qtRepositories = newApp.Test.Actions("Action1").objectRepositories
And for function library, we use ExecuteFile.
Kind of similar to what you do, except it seems like you do it from the main test script dynamically while we are loading/associating the files once in the beginning of the script and not on demand dynamically.
hmmm...If I have a choice, I think that I still prefer associating my files via the QTP/UFT GUI (File/Settings, Tool/Options, etc.).
Reason: I'm just so used to doing it that way! :>
Last edited by Gilbert; 12-05-2014 at 08:30 AM.
Yeah, there's a 1:1 mapping of OR to Function Library which divides the application up into reusable chunks. In addition to being more efficient you don't run into the issue of two people trying to edit the same repo at the same time.
There really isn't a single stand alone test. All tests are just a call to the framework processor which puts together a test based on what's in the QC steps(which are calls to those reusable chunks using the design steps - call to test feature).
At my current client there is a tendency to add all the func libs, recovery scenarios and repositories to the 1st script you create then 'set as default' that way you are loading 42 files of which 5 or 6 are actually required. Drives me nuts!
I like NU4AN method.
1. It is all about saving run time overhead.
People try to add resources at rum time to add on need basis so that all the resources are not added where only few are actually used for a particular test or suite.
If you are working on small project, you may directly add by UI otherwise generally loading objects on runtime is advisable on need basis.
2. You may chose to use any of the following ways to associate a library:
1) By using ‘File > Settings > Resources > Associate Function Library’ option in QTP.
2) By using Automation Object Model (AOM).
3) By using ExecuteFile method.
4) using LoadFunctionLibrary method.
Below link contains different ways to associate file:
Refer:4 Different Ways to Associate Function Libraries to your QTP Scripts - Automation Repository - Automation Repository
One quick additional difference you may want to know in using ExecuteFile and LoadFunctionLibrary is:
You may debug the code if you use "LoadFunctionLibrary" method, and you'll be able to debug if "ExecuteFile" method is used.
3. You may dinamically load the resources from local drive or QC/ALM as well, for loading the library from QC, following is a quick example:
LoadFunctionLibrary "[QualityCenter\Resources] Resources\QTP Resources\<FolderName>\<FuncLibrary>"
FuncLibrary: Name of QC Resource, but not file name