Test Case + Step Report



This report has been often requested. We'll create an excel file with few information about Test + info about Step as:

  • Path
  • Test Name
  • Description
  • Comments
  • Author
  • Creation Date
  • Step
  • Step Description
  • Step Expected Result




The problems that we meet for this report are 2:


  • Extract those Tests join to the Tree structure
  • Extract Test Steps



The first point is solved with these steps:

  1. In Sub MoveToSubject we retrieve the NodeID
  2. Extract with a query the AL_ABSOLUTE_PATH of the NodeID from ALL_LISTS table
  3. Extract the List of ID (AL_ITEM_ID) of those item whom the AL_ABSOLUTE_PATH starts with the same of the one at the previous point.
  4. Extract all Test Cases with TS_SUBJECT "in" ID of the list of the 3rd point.


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:

  • Create a module global variable that will be the ID of the selected folder (MoveToSubject) that will be set to -1 when we move to a Test (Test_MoveTo)
  • create a new custom button (see WorkFlow Script Editor) in TestPlan Module
  • Put the code in ActionCanExecute to call the Test_ReportTestsSteps Sub if ActionName = "actReportTestsSteps"
  • Creation of the Test_ReportTestsSteps Sub


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


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


'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) & ", "    



   do while Not(RecSet.EOR)

       ID_Folder = ID_Folder & RecSet.FieldValue(0) & ", "




   '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



        '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                


               '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


               set StepList = Nothing

           end if

            set MyTest = Nothing            




        'Save Excel Sheet

        objWkb.SaveAs ("c:\temp\TestAndSteps_" & split(date,"/")(2) & split(date,"/")(1) & split(date,"/")(0) & ".xls"

        'Close and 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




Pag: <    <<