Creating filters can be one of the trickiest things in QC OTA API usage. The first thing you might run into when using Ruby is how you set a filter. In Visual Basic you set a filter like this:
testsetFilter.Filter("CY_CYCLE_ID") = "> 0"
However, in Ruby you have to use the setproperty method e.g.
testsetFilter.setproperty('Filter', 'CY_CYCLE_ID', '> 0')
There were a couple of filters that I was struggling with, but finally got them working. The first one was when I wanted to filter only test cases for some specific test sets in the Test Lab. The working Ruby code looks like this:
testsetf = qc.TestSetFactory
testsetFilter = testsetf.Filter
testsetFilter.setproperty('Filter', 'CY_CYCLE_ID', '> 0')
testsetl = testsetf.NewList(testsetFilter.Text)
testf = qc.TestFactory
testFilter = testf.Filter
testFilter.setproperty('XFilter','TEST-TESTSET',testsetFilter.Text)
testl = testFilter.NewList()
... and I have a list with the filtered tests.
The second problem was with filtering tests for only a specific folder path in Test Plan. The working Ruby code looks like this:
aFilter.setproperty('Filter', 'TS_SUBJECT', "^Subject\\release1^")
... using the TS_PATH property only returned empty value and the trick with TS_SUBJECT property was to use "^ and ^" before and after the value. To get the test path from a list of tests e.g.
thisTest.Field('TS_SUBJECT').Path