使用Com4j从QC获取测试用例列表

时间:2013-02-03 12:26:56

标签: java qc com4j

我编写了以下代码来从QC中检索测试用例列表,但tsTestFactory为空,而当我评估qcConnect.testSetFactory()时,它返回一个Com4j对象。

我在这里做错了什么

ITestSetFactory tsFactory = (qcConnect.testSetFactory()).queryInterface(ITestSetFactory.class);
ITestSetTreeManager tsTreeMgr = (qcConnect.testSetTreeManager()).queryInterface(ITestSetTreeManager.class);

ITestSetFolder tsFolder = (tsTreeMgr.nodeByPath(nodePath)).queryInterface(ITestSetFolder.class);
IList its1 = tsFolder.findTestSets(testSetName, false, "");

Iterator itr = its1.iterator();
while (itr.hasNext())
{
    Com4jObject comObj = (Com4jObject) itr.next();
    ITestSet sTestSet = comObj.queryInterface(ITestSet.class);
    System.out.println(sTestSet.name());
    System.out.println(sTestSet.id());

    ITestFactory tsTestFactory = (qcConnect.testSetFactory()).queryInterface(ITestFactory.class);
    ITSTest sTSTest = (tsTestFactory.item(sTestSet.id())).queryInterface(ITSTest.class);

    System.out.println(sTSTest.name());
}

1 个答案:

答案 0 :(得分:2)

TestFactory与TestSetFactory不同,所以你不能这样做:

ITestFactory tsTestFactory =(qcConnect.testSetFactory())。queryInterface(ITestFactory.class);

尝试使用qcConnect.testFactory而不是qcConnect.testSetFactory。