This post explains how to load multiple libraries at runtime from Quality Center in a QTP test. As the test size grows, it is better to associate or load function library at runtime with all the tests.
Note we should associate an initialization library with each of the test and then perform following work in the initialization library.
- Load all the function library with the test
- Load the shared object Repository with the test.
- Remove the local object repository with the test to avoid object conflict
- Load the environment variables to be used across test
- Close all instances of application.
- Providing the reporter configuration for the test. e.g: allowing reporting in QTP Reporter on scenario of error only
In the current post, we will focus only on how to load multiple libraries at runtime from Quality Center or local folder.
In the case of using local folder structure , the path [QualityCenter] Subject\Project_Name \...... changes to c:\QTP_Automation/......
Const strLibraryNames = "[QualityCenter] Subject\Project_Name\QTP\Libraries\Library1.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library2.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library3.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library4.vbs"
callfunc_LoadFunctionLibrary(strLibraryNames)
Function func_LoadFunctionLibrary(strLibraryName)
''Load multiple Library Files seperated by '>'
collLibrary = split(strLibraryName, ">")
''Now collLibrary is an array with each element in array storing the path of library
For i = 0 to ubound(collLibrary)
LoadFunctionLibrary collLibrary(i)
Next
End Function