我正在尝试使用VBScript为具体选定的测试用例更新测试用例状态,但是我无法识别所选(突出显示的测试用例)行。
QC中有一些功能,例如“选择导出”或“选择报告”......这意味着可以识别所选项目......
有人可以帮助我如何在VBA或VBS中识别QC中的选定项目并仅为他们更新状态吗?
以下是我堆叠的代码片段:
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
附加图像可以帮助您理解“选定的测试用例”或“所选项目”的含义。
答案 0 :(得分:0)
以下是我找到的解决方案:
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