使用转换为Jar的OTAClient.dll在QC中创建测试集

时间:2014-04-22 13:48:52

标签: java hp-quality-center qc com4j

我正在尝试将我的应用程序与QC链接,并通过它创建动态测试集。 我可以使用OTAClient.dll检索一些QC数据。使用com4j转换为java接口。现在我需要在QC测试实验室中创建一个新测试集[将首先尝试现有测试]。

ITDConnection QCConnection = ClassFactory.createTDConnection();
    QCConnection.initConnection("http://server/qcbin", "division", "");
    System.out.println("Is connected: "+QCConnection.connected());
    QCConnection.connectProject("domain", "username", "password");
    System.out.println("Database entered: "+QCConnection.dbName());
    QCConnection.bugFactory().queryInterface(ITestFactory.class);
    ITestSetFactory sTestSetFactory = (QCConnection.testSetFactory()).queryInterface(ITestSetFactory.class);
    ITestSet sTestSet = (sTestSetFactory.item(14002)).queryInterface(ITestSet.class);
    System.out.println("Test details by id: "+sTestSet.checkTestInstances("testid"));

以上代码用于获取测试详细信息。任何人都可以帮助创建测试集吗? 感谢

2 个答案:

答案 0 :(得分:2)

你可以做类似的事情:

            ITestSetTreeManager treeManager = connection.testSetTreeManager().queryInterface(ITestSetTreeManager.class);
            ITestSetFolder testSetFolder = treeManager.nodeByPath("Path/where/test/set/should/be/placed").queryInterface(ITestSetFolder.class);
            ITestSetFactory factory = testSetFolder.testSetFactory().queryInterface(ITestSetFactory.class);
            ITestSet testSet = factory.addItem(new Variant(Variant.Type.VT_NULL)).queryInterface(ITestSet.class);
            testSet.name("testSetName");
            testSet.status("Open");
            testSet.post();
            testSet.unLockObject();

答案 1 :(得分:1)

非常感谢Plobpo。现在我们使用root的索引然后创建了一个测试文件夹。 以下代码包含一些其他改进: 还包括添加发布目标,这是我们在此过程中遇到的错误之一。

ITDConnection QCConnection = ClassFactory.createTDConnection();
QCConnection.initConnection("http://nceqcwebp1/qcbin", "E_TRAVEL", "");
QCConnection.connectProject("ETVNRE", "vigupta", "Amadeus!!");
ITestSetTreeManager treeManager = QCConnection.testSetTreeManager().queryInterface(ITestSetTreeManager.class);
ITestSetFolder baseFolder = treeManager.root().queryInterface(ITestSetFolder.class);
baseFolder.addNode("Automatic Test Creation");
ITestSetFolder testSetFolder = treeManager.nodeById(baseFolder.findChildNode("Automatic Test Creation").nodeID()).queryInterface(ITestSetFolder.class);

ITestSetFactory factory = testSetFolder.testSetFactory().queryInterface(ITestSetFactory.class);
ITestSet testSet = factory.addItem(new Variant(Variant.Type.VT_NULL)).queryInterface(ITestSet.class);
testSet.name("Automatic Test Set");
testSet.status("Open");

testSet.field("CY_USER_04", "no schema used");
testSet.field("CY_USER_07", "Non-regression");
testSet.post();
testSet.unLockObject();