2

I am trying to link my application with QC and create dynamic test sets through that. I am able to retrieve some QC data using OTAClient.dll. Used com4j to convert into java interfaces. Now i have a requirement of creating a NEW TEST SET in the QC test lab[Will try for existing tests first].

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"));

The above code is used to get the test details. Can anyone help in creation of test set? Thanks

Vinay Gupta
  • 213
  • 3
  • 16

2 Answers2

2

You can do something similar to this:

            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();
Jacek
  • 87
  • 7
  • Thanks for the help Plobpo. But the code fails to get the node by path. For me the path is: Root/../.. and then the testSets come. Is there anyway of getting the folder id from QC or can we get to the test set in an hierarchical manner? – Vinay Gupta Apr 24 '14 at 10:28
  • Maybe you're pointing incorrect path? If you want to get precise format, you can right click on path and use "Report Selected". – Jacek Apr 25 '14 at 07:59
  • + If you want to get folder Id, you can just copy whole directory with test sets and paste it to notepad :) Last parameter points folder Id. – Jacek Apr 25 '14 at 08:12
2

Well thanks Plobpo. For now we used the index for root and then created a test folder. Here is the code with some additional improvements: Also includes adding release target which was one of the error we faced in the process.

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();
Vinay Gupta
  • 213
  • 3
  • 16