This report has been often requested. We'll create an excel file with few information about Test + info about Step as:
The problems that we meet for this report are 2:
The first point is solved with these steps:
The second point can be done using OTA Api to access, through Test object, to the DesignStepFactory and return the Step list.
__________________________________________________________________________
Explain and Implementation
For the extraction is necessary:
1. Decleration of the module global variable ID_Subject
Dim ID_Subject
2. Insert Code to set the ID_Subject variable
Sub MoveToSubject(Subject)
On Error Resume Next
ID_Subject = Subject.NodeID
On Error Goto 0
End Sub
3. Set at -1 the ID_Subject variable when the focus is on a Test object
Sub Test_MoveTo
On Error Resume Next
ID_Subject = -1
On Error Goto 0
End Sub
4. Call the Sub from ActionCanExecute
Function ActionCanExecute(ActionName)
On Error Resume Next
Dim Res
Res = True
if ActionName = "act_ReportTestsSteps" then
Test_ReportTestsSteps
end if
ActionCanExecute = Res
On Erro Goto 0
End Function
5. Creation of the Extraction Sub
Sub Test_ReportTestsSteps
On Error Resume Next
Dim MyComm, RecSet, strAbsPath, strQuery, ID_Folder, r, RecSet2
'If ID_Subject is -1 it means the focus isn't on a folder. Quit
if ID_Subject = -1 then
msgbox "Select a Folder!!!", vbExclamation + vbSystemModal, "QC - Error on Folder Focus"
exit Sub
end if
strQuery = "Select AL_ABSOLUTE_PATH From ALL_LISTS " & _
"Where AL_ITEM_ID = " & ID_Subject
'Creation of the Command object
set MyComm = TDConnection.Command
'Loading of the Query
MyComm.CommandText = strQuery
'Execution and saving of the Query
Set RecSet = MyComm.Execute
'Move to the 1st record
RecSet.First
'Salve data in strAbsPath
strAbsPath = RecSet.FieldValue(0)
Set RecSet = Nothing
'Extraction of all Tree Structure Folder ID of the selected Folder
MyComm.CommandText = "Select AL_ITEM_ID From ALL_LISTS " & _
"Where AL_ABSOLUTE_PATH LIKE '" & strAbsPath & "%'"
'Query Execution
Set RecSet = MyComm.Execute
'Check if RecordSet is not empty
if RecSet.RecordCount > 0 then
'Ok, it means there are subfolders. I load all the ID List
'Then I create the query on TEST table to extract all Test ID
'ID_Folder is a variable consists of all Folder ID.
'Inizialyze with the Selected Subject ID
ID_Folder = str(ID_Subject) & ", "
RecSet.First
do while Not(RecSet.EOR)
ID_Folder = ID_Folder & RecSet.FieldValue(0) & ", "
RecSet.Next
loop
'remove the last space and comma chars
ID_Folder = left(ID_Folder, len(ID_Folder) - 2)
'Create the query to extract all TestID
strQuery = "Select TS_TEST_ID From TEST " & _
"WHERE TS_SUBJECT IN (" & ID_Folder & ")"
'Load the query into CommandText of MyComm
MyComm.CommandText = strQuery
'Query Execution and save data into RecSet2
set RecSet2 = MyComm.Execute
'Check the RecSet2 isn't empty
if RecSet2.RecordCount > 0 then
RecSet2.First
'Excel object Creation
set objXLS = CreateObject("Excel.Application")
objXLS.Visible = False
set objWkb = objXLS.Workbooks.Add
set objWks = objWkb.Worksheets(1)
objWks.Name = "Report Test+Step"
'write excel header
objWks.Cells(1,1).Value = "Path"
objWks.Cells(1,2).Value = "Test Name"
objWks.Cells(1,3).Value = "Description"
objWks.Cells(1,4).Value = "Comments"
objWks.Cells(1,5).Value = "Author"
objWks.Cells(1,6).Value = "Creation Date"
objWks.Cells(1,7).Value = "Step Name"
objWks.Cells(1,8).Value = "Step Description"
objWks.Cells(1,9).Value = "Step Expected Result"
r = 2
'Cycle for all Test ID, retrieve the Test object and extract all the infos
do while Not(RecSet2.EOR)
set MyTest = TDConnection.TestFactory.Item(RecSet.FieldValue(0))
'Check if test has at least 1 step, otherwise I'll write only Test Infos
if MyTest.DesStepsNum = 0 then
' Retrieve the test path
objWks.Cells(r,1).Value = TDConnection.TreeManager.NodeByID(MyTest.Field("TS_SUBJECT")).Path
objWks.Cells(r,2).Value = MyTest.Name
objWks.Cells(r,3).Value = MyTest.Field("TS_DESCRIPTION")
objWks.Cells(r,4).Value = MyTest.Field("TS_DEV_COMMENTS")
objWks.Cells(r,5).Value = MyTest.Name("TS_RESPONSIBLE")
objWks.Cells(r,6).Value = MyTest.Name("TS_CREATION_DATE")
'increase of the row
r = r + 1
else
'retrieve the step list
set StepList = MyTest.DesignStepFactory.NewList("")
'do a for cycle for each step
for each elStep in StepList
' Retrieve the test path
objWks.Cells(r,1).Value = TDConnection.TreeManager.NodeByID(MyTest.Field("TS_SUBJECT")).Path
objWks.Cells(r,2).Value = MyTest.Name
objWks.Cells(r,3).Value = MyTest.Field("TS_DESCRIPTION")
objWks.Cells(r,4).Value = MyTest.Field("TS_DEV_COMMENTS")
objWks.Cells(r,5).Value = MyTest.Field("TS_RESPONSIBLE")
objWks.Cells(r,6).Value = MyTest.Field("TS_CREATION_DATE")
objWks.Cells(r,7).Value = elStep.Name
objWks.Cells(r,8).Value = elStep.Field("DS_DESCRIPTION")
objWks.Cells(r,9).Value = elStep.Field("DS_EXPECTED")
'increase the excel row
r = r + 1
next
set StepList = Nothing
end if
set MyTest = Nothing
RecSet2.Next
loop
'Save Excel Sheet
objWkb.SaveAs ("c:\temp\TestAndSteps_" & split(date,"/")(2) & split(date,"/")(1) & split(date,"/")(0) & ".xls"
'Close and Quit
objWkb.Close
objXLS.Quit
set objXLS = Nothing
set objWkb = Nothing
set objWks = Nothing
end if
set RecSet2 = Nothing
end if
set RecSet = Nothing
set MyComm = Nothing
On Error Goto 0
End Sub
_______________________________________________________________________
Questo sito è stato realizzato con Jimdo! Registra il tuo sito gratis su https://it.jimdo.com