Report about Executions + Defects



Report consists of a unique excel sheet with these informations:


  • TestLab Path (f.e. Root\Folder1\Folder1_1\...)
  • TestSet Name
  • Total Number of Tests
  • Passed
  • Failed
  • No Run
  • Not Completed
  • N/A
  • Tot Bug
  • New
  • Open
  • Assigned
  • Fixed
  • Reopen
  • Rejected
  • Closed



Before extract information about test executions and linked bugs it's very important to understand which are the relations between objects. Here are the hierarchy of the objects:








Data Extraction - Summary:



  • Every Test Case gets AT LEAST one STEP
  • Defects are created only during the Run Execution, more deeply during Step Execution.


  1. The extraction of data will be done through the selection of a custom button inside the TestLab section that will work only if a folder is selected.
  2. If the check of the folder is OK then it will extract all the TestSets under the selected folder and its hierarchy. We'll use the FindTestSets method of TestSetFolder object.
  3. With a for cycle for each TestSet we'll extract the TestInstance List
  4. We'll do an internal for cycle for each TestInstance to retrieve the execution status and access to the last Run, if exists.
  5. From the Run we'll analyze all single Step execution to understand if it is linked to a Bug. If a Bug exists we'll increase the total counter and the counter of the bug status.





Implementation on the Product


See the WorkFlow Script Editor  to know how to create a custom button.


Suppose the Action linked to the button is actReportRunDefect.


1. We'll insert into the ActionCanExecute the call to the main Sub into TestLab.


Function ActionCanExecute(ActionName)

On Error Resume Next

Dim Res

Res = True


   if ActionName = "actReportRunDefect" then

        'Call to Sub under TestLab


   end if


ActionCanExecute = Res

On Error Goto 0

End Function



2. Into TestLab section put the main Sub TestSet_ReportRunDefect


Sub TestSet_ReportRunDefect

On Error Resume Next

Dim objXLS, objWkb, objWks, i

Dim myTestSetList, myListaIstanze

Dim varRes, arrRes, j, col


'Check if focus is on a folder otherwise quit

'Use the global object objFold_TL.

'This object must be declared in common module

'and put this code into the event MoveToFolder:

'          set objFold_TL = Folder

'and this one in ExitModule (common)

'and this one in TestSet_MoveTo (TestLab):

'          set objFold_TL = Nothing


if objFold_TL.IsNull then

   msgbox "I don't have the focus on the folder. Select a Folder.", vbCritical + vbSystemModal, "Quality Center - Folder Focus Error"

   exit sub

end if


'If I'm here it means that the check of the folder is ok



'Excel Objects Creation.


set objXLS = CreateObject("Excel.Application")

objXLS.Visible = False    

set objWkb = objXLS.Workbooks.Add

set objWks = objWkb.Worksheets(1)


'Rename the sheet

objWks.Name = "Report Exec and Bug"


'Header of the columns

objWks.Cells(1,1).Value = "Path"

objWks.Cells(1,2).Value = "TestSet"

'The 3rd column is empty

objWks.Cells(1,4).Value = "Number of Test"

objWks.Cells(1,5).Value = "Passed"

objWks.Cells(1,6).Value = "Failed"

objWks.Cells(1,7).Value = "No Run"

objWks.Cells(1,8).Value = "Not Completed"

objWks.Cells(1,9).Value = "N/A"

'10th column empty

objWks.Cells(1,11).Value = "Tot Bug"

objWks.Cells(1,12).Value = "New"

objWks.Cells(1,13).Value = "Open"

objWks.Cells(1,14).Value = "Assigned"

objWks.Cells(1,15).Value = "Fixed"

objWks.Cells(1,16).Value = "Reopened"

objWks.Cells(1,17).Value = "Rejected"

objWks.Cells(1,18).Value = "Closed"




'Extract the TestSet list under the tree structure starting from the

'selected folder

set myTestSetList = objFold_TL.FindTestSets("",False,"")


'increase the row number

i = 2


'For Cycle for each TestSets and analyze them

for each elTS in myTestSetList


    '1st I retrieve the TestSet folder to retrieve the path to write

    'on excel file. I do this in a one instruction

    objWks.Cells(i,1).Value = elTS.TestSetFolder.Path


    'Write the TestSet Namein the 2nd field of the excel

    objWks.Cells(i,2).Value = elTS.Name

    'Retrieve the TestInstance List of the TestSet

    set myListaIstanze = elTS.TSTestFactory.NewList("")


    'Write the Tot Number of TestInstance of the TestSet

    objWks.Cells(i,4).Value = myListaIstanze.Count


    'I analyze al TestInstance callling a function that returns

    'a variable with all data divided by a comma

    varRes = TestSet_Analizza_ListaIstanze(myListaIstanze)


    'I create the array of the result splitting the variable on the comma char.

    arrRes = split(varRes,",") 


    'write all data into the excel file

    for j = 0 to Ubound(arrRes)

         'use a var col for the column that must be write

         'We've put a space for the 10th column 10 so I need to add 1

         'to jump it.

         'When j=0 it means that column is 5 so when j = 5

         'column must be increased of 1, so col = 11

         if j = 5 then

           col = j + 5 + 1


           col = j + 5

         end if


         'write the information

         objWks.Cells(i,col).Value = arrRes(j)




    set myListaIstanze = Nothing


    i =  i + 1  'increase the row to write into the excel file




'save excel file

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

'Close the workbook


'quit from excel application



set objWks = Nothing

set objWkb = Nothing

set objXLS = Nothing


set myTestSetList = Nothing

On Error Goto 0

End Sub


Function TestSet_Analizza_ListaIstanze(theList)

On Error Resume Next

Dim intPassed, intFailed, intNoRun, intNotComp, intNA

Dim intTotBug, intNew, intOpen, intAssigned, intFixed, intReopened, intRejected

Dim intClosed, Res


Dim RunList, UltimoRun, StepList

Dim myComm, RecSet, myBug


Res = ""


'Inizialyze all counter to 0

intPassed = 0

intFailed = 0

intNoRun = 0

intNotComp = 0

intNA = 0


intTotBug = 0

intNew = 0

intOpen = 0

intAssigned = 0

intFixed = 0

intReopened = 0 

intRejected = 0

intClosed = 0


'Now I do a for cycle for each TestInstance

for each elIst in theList

    'retrieve the information about the TestInstance Execution Status

    select case elIst.Status

             case "Passed": intPassed = intPassed + 1  

             case "Failed": intFailed = intFailed + 1

             case "No Run": intNoRun = intNoRun + 1

             case "Not Completed": intNotComp = intNotComp + 1

             case "N/A": intNA = intNA + 1

    end select


    'retrieve the Run List of the Instance to retrieve bugs

    set RunList = elIst.RunFactory.NewList("")

    if RunList.Count > 0 then   'it means that at least there is a bug.


       'istance of the Last Execution

       set UltimoRun = elIst.LastRun

       'extract the step list of the Run.

       'I'm sure that at least one step has been execute because

        'it is a prerequisit that Test Case have at least one Step       

       set StepList =  UltimoRun.StepFactory.NewList("")      

       for each elStep in StepList

           'Check if there is a bug for this step.

           'I need to execute a query

           set myComm = TDConnection.Command

           myComm.CommandText = "Select LN_BUG_ID from LINK where " & _

           "LN_ENTITY_TYPE = 'STEP' and LN_ENTITY_ID = " & elStep.ID


           'Execute the query and save the result on the RecSet

           set RecSet = myComm.Execute


           'Check that RecSet has some record

           if RecSet.RecordCount > 0 then                                          

              'move the the first record



              'I need to do a cycle for all recordset row

              do while Not(RecSet.EOR)


                 'increase the Total Bug Counter

                 intTotBug = intTotBug + 1


                 'create Bug Object by taking the ID from the RecordSet

                 set myBug = TDConnection.BugFactory.Item(RecSet.FieldValue(0))


                 'Check Bug Status to increase counters

                 Select case myBug.Status

                           case "New": intNew = intNew + 1

                           case "Open": intOpen = intOpen + 1

                           case "Assigned": intAssigned = intAssigned + 1

                           case "Fixed": intFixed = intFixed + 1

                           case "Reopened": intReopened = intReopened + 1

                           case "Rejected": intRejected =  intRejected + 1

                           case "Closed": intClosed = intClosed + 1

                 End Select






           end if


           set RecSet = Nothing

           set myComm = Nothing



       set StepList = Nothing

    end if

    set RunList = Nothing



'now I have all counters I add them to a variable to return to the function

res = str(intPassed) & "," & _

str(intFailed) & "," & _

str(intNoRun) & "," & _

str(intNotComp) & "," & _

str(intNA) & "," & _ 

str(intTotBug) & "," & _

str(intNew) & "," & _

str(intOpen) & "," & _

str(intAssigned) & "," & _

str(intFixed) & "," & _

str(intReopened) & "," & _ 

str(intRejected) & "," & _



TestSet_Analizza_ListaIstanze = Res


On Error Goto 0

End Function




Pag: >    >>