How to get Sub folder name using Test ID in HP QC OTA Java

2.2k views Asked by At

Actually need to get SubFolder name using Test ID which is present under

Test Plan > Subject > Sample(Folder Name) > Scenario (Sub Folder) > TC1 (Test- BPT)

I need to retrieve Scenario as subfolder name using TestID

Here is my code

ITestSetTreeManager tstm = tdc.testSetTreeManager().queryInterface(ITestSetTreeManager.class);   
ITestSetFolder tsf = tstm.nodeByPath("Root\\Lab").queryInterface(ITestSetFolder.class); 

    IList testSets = tsf.findTestSets("Regression", false, "");   

    for (Com4jObject testSetObj : testSets)   
    {   
        ITestSet testSet = testSetObj.queryInterface(ITestSet.class);   

        System.out.println(testSet.name());   
        IBaseFactory testFactory = testSet.tsTestFactory().queryInterface(IBaseFactory.class);   
        IList testInstances = testFactory.newList("");   
        for (Com4jObject testInstanceObj : testInstances)   
        {   
            ITSTest testInstance = testInstanceObj.queryInterface(ITSTest.class);   
            System.out.println(testInstance.testName());
            Object ID =  testInstance.testId();
            System.out.println(ID.toString());
         }
    }

Using ID object I could be able to retrieve TestId and also I need to retrieve the sub folder name.

For that tried with TS_SUBJECT but it fails

Can anyone share your views on fetching sub folder name / TS_SUBJECT field value.

1

There are 1 answers

0
Ganeshja On

Finally retrieved the Folder (Sub folder) name of current Business Process Test by using ISubjectNode using java Com4jObject

ITestFactory iTestFactory = QCConnection.testFactory().queryInterface(ITestFactory.class);
Com4jObject comobjTest = iTestFactory.item(testInstance.testId());
ITest iTest = comobjTest.queryInterface(ITest.class);
Com4jObject SubjectField = (Com4jObject)iTest.field("TS_SUBJECT");
ISubjectNode SubFolder = SubjectField.queryInterface(ISubjectNode.class);
System.out.println(SubFolder.Name());