Hi again,
This is what I have done
1) I have attached a vbs file containing the code to a test. I am calling this test 'config'.
2)Now in my vapi-xp test I am loading this attachment (vbs file attached in step 1) and then including the code within it so that it is accessible later in my test. I have posted the code I am using below. Now I believe I would have to copy paste this code (posted below) in every vapi-xp test in my project. Although this is more efficient than having multiple copies of the integration code in every test but still there is some repetion. Is this the best option i got or do you think I can reduce the repetition any further.
Thanks again for your help.
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' config [VBScript]
' Created by Quality Center
' 04/02/2010 14:41:55
' ====================================================
'I addedd this to be able to include vbs files in my code
Private Sub IncludeFileAbs (ByVal FileName)
Const ForReading = 1
Dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Dim f: set f = fso.OpenTextFile(FileName,ForReading)
Dim s: s = f.ReadAll()
ExecuteGlobal s
End Sub
' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
' *** VBScript Limitation ! ***
' "On Error Resume Next" statement suppresses run-time script errors.
' To handle run-time error in a right way, you need to put "If Err.Number <> 0 Then"
' after each line of code that can cause such a run-time error.
On Error Resume Next
' clear output window
TDOutput.Clear
' TODO: put your code here
Set TestFact = TDConnection.TestFactory
Set treeMng = TDConnection.TreeManager
Set sourceFolder = treeMng.NodeByPath("Subject\Automation")
Set testF = sourceFolder.testFactory
Set testFilter = testF.Filter
testFilter.Filter("TS_NAME") = "config"
Set TestList = testF.NewList(testFilter.Text)
set tst=TestList.Item(1)
Set AttachFact = tst.Attachments
Set theAttachCol = AttachFact.NewList("")
Set theAttach = theAttachCol.Item(1)
theAttach.Load True, ""
'msgbox theAttach.FileName
IncludeFileAbs (theAttach.FileName)
msgbox abc
If Not Debug Then
End If
' handle run-time errors
If Err.Number <> 0 Then
TDOutput.Print "Run-time error [" & Err.Number & "] : " & Err.Description
' update execution status in "Test" mode
If Not Debug Then
CurrentRun.Status = "Failed"
CurrentTSTest.Status = "Failed"
End If
End If
End Sub
'The content of the attachment vbs file is as below
'--------------------------------------------------------------------------
Dim abc
abc="bcd"
'--------------------------------------------------------------------------