0

I'm trying to update a test case status using VBScript for a concrete selected test cases, however I'm unable to identify the selected (highlighted test cases) rows.

There are features in QC like "export selected" or "report selected"... which mean it is possible to identify selected items...

Can someone help me how to identify in VBA or VBS the selected items in QC and update the status only for them?

Here is the fragment of code where I'm stacked in:

Sub change_status() 
    'code with connections etc

    'start iterating through all test cases
    For Each TestCase In TestSetTestsList
        'identify the test case was selected/highlighted
        If TestCase.Field("selected") = True Then
           TestCase.Field("TS_STATUS") = "passed"  '"failed" etc
           TestCase.Post
           TestCase.Refresh
        End If
    Next

    MsgBox ("The status successfully updated for all selected test cases")
End Sub

The attached image can help you understand what I mean by "selected test case" or "selected item".

selected test cases

GlennV
  • 3,471
  • 4
  • 26
  • 39
Victor
  • 1
  • 4

1 Answers1

0

And here is the solution I found:

Function TestSet_CanRemoveTests(Tests)

 result = msgbox ("Would you like to update the status?", vbYesNo, "Update Status")
 Select Case result
 Case vbYes
 val = "Passed = 1 ; No Run = 2 ; Blocked = 3 ; Failed = 4; Not Delivered = 5; N/A = 6"
 title = "Choose status"
 myValue = InputBox(val, title)
      If myValue="1" Then
      stts = "Passed"
      ElseIf myValue="2" Then
      stts = "No Run"
      ElseIf myValue="3" Then
      stts = "Blocked"
      BugID = inputbox ("Please insert a Defect ID you would like to link with:", "Defect ID")
              Select case BugID
                     case false
                     TestSet_CanRemoveTests = false
                     Exit Function
              End Select
      ElseIf myValue="4" Then
      stts = "Failed"
      ElseIf myValue="5" Then
      stts = "Not Delivered"
      ElseIf myValue="6" Then
      stts = "N/A"
      ElseIf myValue = false then
      TestSet_CanRemoveTests = false
      Exit Function
      End If


 For Each TestCase in Tests
 Set MyTest = TsTestFactory.Item(TestCase) 'without TDConnection

 If myValue = "3" then
 Set objBugLinkFac = MyTest.BugLinkFactory
 Set objLink = objBugLinkFac.AddItem(BugID)

 objLink.LinkType = "Related"
 objLink.Post

 MyTest.Field("TC_STATUS") = stts
 MyTest.Post

 Set objLink = Nothing
 Set objBugLinkFac = Nothing

 Else:
 MyTest.Field("TC_STATUS") = stts
 MyTest.Post
 End If

 Set MyTest = Nothing
 t = t + 1
 Next

 msgbox("Done! Total number of affected tests is - " & t)
 TestSet_CanRemoveTests = false

 Case vbNo
 TestSet_CanRemoveTests = DefaultRes
 End Select
 'On Error GoTo 0
End Function
Victor
  • 1
  • 4