3

I am trying to execute the test cases in QC ALM through an Excel macro. I am able to access the tests in testlist, but I am not able to find the particular test case I need to execute by its ID.

Below is the sample code I am using:

Set tsTreeMgr = tdConnection.testsettreemanager
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
' --Search for the test set passed as an argument to the example code
Set tsList = tsFolder.FindTestSets("Test Set Name")

'------Accessing the Test Cases inside the Test SEt ----

Set theTestSet = tsList.Item(1)
For Each testsetfound In tsList
    Set tsFolder = testsetfound.TestSetFolder
    Set tsTestFactory = testsetfound.tsTestFactory
    Set tsTestList = tsTestFactory.NewList("")

    For Each tsTest In tsTestList
        MsgBox (tsTest.Name+","+ tsTest.ID)
        testrunname = "Test Case name from excel sheet"
        '----Accesssing the Run Factory ---
        Set RunFactory = tsTest.RunFactory
        Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
        obj_theRun.Status = "Passed"
        obj_theRun.Post
    Next
Next

Any help to get TestCase in testset of testlab to execute would be great help.

Community
  • 1
  • 1

1 Answers1

2

I think you are looking for the TestId property of the TSTest object. So in your loop you could just test whether TestId matches the value from Excel:

If tsTest.TestId = testidfromexcel Then
    ' do something
End If

Or you can use a Filter to only get the TSTest instances from your Test Set that matches the respective test ID from Excel:

Set testSetFilter = tsTestFactory.Filter
testSetFilter.Filter("TC_TEST_ID") = testidfromexcel
Set tsTestList = testSetFilter.NewList()

Now your tsTestList should only contain test instances from the test with the ID from Excel.

Roland
  • 1,220
  • 1
  • 14
  • 29