Excel 用于导出测试用例以及相关需求 ID 的宏

Excel macro to export the test cases along with the associated requirement Ids

我有一个从 QC 11 导出测试用例的宏,但我无法获得映射到它们的需求 ID。

 For Each Node In NodesList
    Set TestTree = TreeMgr.NodeByPath(Node)
    Set TestFactory = TestTree.TestFactory
    Set TestList = TestFactory.NewList("") 'Get a list of all from node.

    'Iterate through all the tests.
    For Each TestCase In TestList
        Dim DesignStepFactory, DesignStep, DesignStepList
        Set DesignStepFactory = TestCase.DesignStepFactory
        Set DesignStepList = DesignStepFactory.NewList("")
  If DesignStepList.Count = 0 Then
            Sheet.Cells(Row, 1).Value = Trim(TestCase.Field("TS_TEST_ID"))
            Sheet.Cells(Row, 2).Value = Trim(TestCase.Field("TS_NAME"))
            Sheet.Cells(Row, 3).Value = Trim(TestCase.Field("TS_DESCRIPTION"))
            Sheet.Cells(Row, 4).Value = Trim(TestCase.Field("TS_RESPONSIBLE"))
            Sheet.Cells(Row, 5).Value = Trim(TestCase.Field("TS_SUBJECT").Path)
            Row = Row + 1
        Else
            For Each DesignStep In DesignStepList
                'Save a specified set of fields.
            Sheet.Cells(Row, 1).Value = Trim(TestCase.Field("TS_TEST_ID"))
            Sheet.Cells(Row, 2).Value = Trim(TestCase.Field("TS_NAME"))
            Sheet.Cells(Row, 3).Value = Trim(TestCase.Field("TS_DESCRIPTION"))
            Sheet.Cells(Row, 4).Value = Trim(TestCase.Field("TS_RESPONSIBLE"))
            Sheet.Cells(Row, 5).Value = Trim(TestCase.Field("TS_SUBJECT").Path)

                'Save the specified design steps.
                Sheet.Cells(Row, 6).Value = Trim(DesignStep.Field("DS_STEP_NAME"))
                Sheet.Cells(Row, 7).Value = Trim(DesignStep.Field("DS_DESCRIPTION"))
                Sheet.Cells(Row, 8).Value = Trim(DesignStep.Field("DS_EXPECTED"))
                Row = Row + 1
            Next
        End If
    Next
Next

我在这里获取测试用例 ID、名称、描述、设计器和路径。但是我没有得到映射到它的需求 ID。

任何帮助将不胜感激。提前致谢。

由于一项测试可以涵盖多个需求,因此没有与测试相关联的单一需求 ID。您可以使用测试对象中的方法 GetCoverList 来获取测试涵盖的所有需求的列表——类似于:

Set RequirementList = TestCase.GetCoverList