Dim runStepList
Dim CurrentRun ' object which holds the current run
'=============================================================================================
'@purpose- this function will copy design steps from 'design steps' tab to current run of test in QC
'make sure qtp and qc connection has been established before runnning the test
'=============================================================================================
Function CopyDesingSteps()
On error resume next
Dim otest
if QCUtil.IsConnected =False then
msgbox "Please establish connection to ALM first."
'ExitAction
Exit function
End if
set CurrentRun = QCUtil.CurrentRun
' copy design steps to current run
CurrentRun.CopyDesignSteps
GetDesignSteps CurrentRun
intTotalNumberOfUpdatedSteps=0
End Function
'=============================================================================================
'@ purpose- this function will retrive the list of steps of current run in to runStepList
'=============================================================================================
Function GetDesignSteps(CurrentRun)
'On error resume next
Dim intStepcount
Set runStepF = CurrentRun.StepFactory
Set runStepList = runStepF.NewList("")
intTotalNumberOfSteps=runStepList.Count
For intStepcount = 1 To runStepList.Count
runStepList.Item(intStepcount).Field("ST_STATUS") ="Not Completed"
runStepList.Item(intStepcount).Field("ST_ACTUAL") ="Not Completed"
runStepList.Post
Next
Set runStepF = nothing
End Function
'=============================================================================================
'@purpose- This function will update specified step with status and actual in test run result
'=============================================================================================
Function UpdateStep(byval stepID,byval strStatus,byval strData)
'On error resume next
If strStatus = True Then
strStatus="Passed"
'
else
strStatus="Failed"
End If
' update step status and step actuals
runStepList.Item(stepID).Field("ST_STATUS") =strStatus
runStepList.Item(stepID).Field("ST_ACTUAL") =strData
runStepList.Post
End Function
Sub EndTest()
CurrentRun.Post
Set runStepList= nothing
Set Currentrun = nothing
end Sub
Sub BeginTest()
' copy design steps to current run
CopyDesingSteps
End Sub
In qtp script at the start call BeginTest() function then use UpdateStep to update each step and at the end use EndTest to post result in qc