woensdag 6 februari 2008

Schedule/execute testset run in Quality Center from Windows (VBScript)

You want to schedule and execute an automated test run every day at a certain hour. You need your results saved in QC. Here's a simple solution for scheduling by using following script in the windows scheduler.

-----------------
VBScript:

Dim QCConnectionSet
QCConnection = CreateObject("TDApiOle80.TDConnection")


QCConnection.InitConnectionEx "server_address" ' <--------------- Fill in server addressQCConnection.login "user", "pwd" '<------------------- FILL in user/pwd
QCConnection.Connect "domain_name", "project_name" '<----------- FILL Domain/Project

Set TSetFact = QCConnection.TestSetFactory

Set tsTreeMgr = QCConnection.TestSetTreeManager
nPath = "Root\test" '<------------- FILL IN PATH TO TESTSET

Set tsFolder = tsTreeMgr.NodeByPath(nPath)
If tsFolder Is Nothing Then

msgbox "error"
End If

Set tsList = tsFolder.FindTestSets("name_of testset") '<------- FILL IN NAME OF TESTSET

If tsList.Count > 1 Then
MsgBox "FindTestSets found more than one test set: refine search"
ElseIf tsList.Count <>
MsgBox "FindTestSets: test set not found"
End If

Set theTestSet = tsList.Item(1)

Set Scheduler = theTestSet.StartExecution("")
Scheduler.RunAllLocally = True
Scheduler.HostTimeOut = 100000

Scheduler.runSet execStatus = Scheduler.ExecutionStatus
RunFinished = False
while RunFinished = False
execStatus.RefreshExecStatusInfo "all", True
RunFinished = execStatus.Finished
wend
QCConnection.Disconnect
QCConnection.Logout
Set QCConnection = Nothing

---------------

Very crude! but it does the job! You just need an existing testset, the script will execute it at any time you want using your windows scheduler.
I'm sorry for the absolute lack of comments, but you're smart, you can figure it out. :)

1 opmerking:

SrinivasRadaram zei

Hi,

Would u like to share any documents on VB scripting pls?

I am into WinRunner and want to start learning VB scripting.

Pls reply me.