如何使用VBA和QC OTA查找文件夹中的测试集数量?

时间:2015-01-29 07:01:05

标签: excel-vba qc vba excel

我正在使用QC OTA编写VBA代码来提取每天发送到客户端所需的执行报告,有没有办法找到带有文件夹的测试集数量,这样我就可以运行循环来查找传递的总数,失败脚本?现在我使用手动输入的值sTestSetCount

'Piece of the whole script
For sCount = 1 To sTestSetCount
    Set tsList = tsFolder.FindTestSets("P0049585")
    Dim oTestSet: Set oTestSet = tsList.NewList("").Item(sCount).TsTestFactory 'Item(1) Refers to the 1st test set in the path
    Dim testFilter1: Set testFilter1 = oTestSet.Filter

    'To Filter by Passed status
    testFilter1.Filter("TC_STATUS") = "Passed"
    vPass = vPass + oTestSet.NewList(testFilter1.Text).Count

    'To Filter by Failed Status
    testFilter1.Filter("TC_STATUS") = "Failed"
    vFail = vFail + oTestSet.NewList(testFilter1.Text).Count

    'To Filter by No Run status
    vNR = vNR + oTestSet.NewList("[Filter]{TableName:TESTCYCL,ColumnName:TC_STATUS,LogicalFilter:" & Chr(39) & "No" & Chr(32) & "Run" & Chr(39) & ",VisualFilter:" & Chr(39) & "No" & Chr(32) & "Run" & Chr(39) & ",NO_CASE:}").Count

    'To Filter by Not Completed status
    vNC = vNC + oTestSet.NewList("[Filter]{TableName:TESTCYCL,ColumnName:TC_STATUS,LogicalFilter:" & Chr(39) & "Not" & Chr(32) & "Completed" & Chr(39) & ",VisualFilter:" & Chr(39) & "Not" & Chr(32) & "Completed" & Chr(39) & ",NO_CASE:}").Count

    'To Filter by  N\A
    testFilter1.Filter("TC_STATUS") = "N/A"
    vNA = vNA + oTestSet.NewList(testFilter1.Text).Count

    'To Filter by Blocked
    testFilter1.Filter("TC_STATUS") = "Blocked"
    vBlocked = vBlocked + oTestSet.NewList(testFilter1.Text).Count

Next sCount
Worksheets("Status").Range("C10").Value = vPass + vFail + vNR + vNC + vNA + vBlocked
Worksheets("Status").Range("D10").Value = vPass
Worksheets("Status").Range("E10").Value = vFail
Worksheets("Status").Range("F10").Value = vNC
Worksheets("Status").Range("G10").Value = vBlocked
Worksheets("Status").Range("H10").Value = vNA
Worksheets("Status").Range("H11").Value = (vPass + vFail) / (vPass + vFail + vNR + vNC + vBlocked) * 100 & " %"
Application.StatusBar = "Execution Percentage = " & ((vPass + vFail) / (vPass + vFail + vNR + vNC + vBlocked) * 100) & "%"

2 个答案:

答案 0 :(得分:0)

只需获取测试实验室文件夹的TestSetFactory并创建一个NewList,而不使用过滤器来获取该文件夹中的所有测试集:

treeMgr = tdc.TestSetTreeManager
folder = treeMgr.NodeByPath("someTestLabPath")
testSetFact = folder.TestSetFactory
testSetList = testSetFact.NewList("")
sTestSetCount = testSetList.Count

答案 1 :(得分:0)

此声明将有助于计算无运行测试用例的计数,但如果您在&#34上使用更多过滤器,则不会运行"测试用例。然后尝试下面的代码

testFilter1.Filter("TC_STATUS") = "'No Run'"

testFilter1.Filter("TS_STATUS") = "Complex"

这将帮助您找到完整的无运行测试用例,并且无需运行多少测试用例。

vNR = vNR + oTestSet.NewList("[Filter]{TableName:TESTCYCL,
ColumnName:TC_STATUS,LogicalFilter:" & Chr(39) & "No" & Chr(32) & "Run" & Chr(39) & 
",VisualFilter:" & Chr(39) & "No" & Chr(32) & "Run" & Chr(39) & 
",NO_CASE:}").Count

由于 PT:)