Sub TSTestsCoveringReqs ( _ theTestSet As TestSet, Req1 As Req) ' Getting those test instances that do, and those that do not, cover a requirement ' This example demonstrates using a filter to find ' those test instances of a given test set that cover ' a given requirement, and then to find the the test ' instances that do not cover that requirement. On Error GoTo RQTest_Err Dim TestInstFilter As TDFilter, xFilter As TDFilter Dim aStr$ ' Create the first clause of the filter ' Get the test instances that belong ' to the test set passed to this routine. ' No filter fields are specified, so all the test instances ' of the test set are included. Dim testInstanceF As TSTestFactory Set testInstanceF = theTestSet.TSTestFactory Set TestInstFilter = testInstanceF.Filter aStr = TestInstFilter.GetXFilter("TSTEST-REQ", True) Debug.Print aStr aStr = TestInstFilter.GetXFilter("TSTEST-REQ", False) Debug.Print aStr ' ' Create the second clause of the filter: The set of ' requirements containing the single requirement ' passed to the routine. Dim reqF As ReqFactory Set reqF = tdc.ReqFactory ' tdc is the TDConnection object. Set xFilter = reqF.Filter xFilter.Filter("RQ_REQ_NAME") = Req1.name ' Now combine the two, creating the join criteria: ' Main clause: Get all the test instances of the given test set. ' Second clause: Get the Req objects where the name ' is "Req1". ' The result: Get all test instances in the given test set ' that are associated with (cover)the given requirement. TestInstFilter.SetXFilter "TSTEST-REQ", True, xFilter.Text ' Debug.Print ' Debug.Print "TestInstFilter.Text after xFilter set: " ' Debug.Print TestInstFilter.Text ' ' TestInstFilter.Text after xFilter set: ' [Filter]{ ' FLT:[X], ' TYPE:TSTEST-REQ, ' EXISTS_IN_IDS:Y, ' IN_IDS:\0000006a\[Filter]{ ' TableName:REQ, ' ColumnName:RQ_REQ_NAME, ' LogicalFilter:Req1, ' VisualFilter:Req1, ' NO_CASE: ' } ' ' } ' Output the results. aStr = TestInstFilter.GetXFilter("TSTEST-REQ", True) Debug.Print "Inclusive is True:" Debug.Print aStr aStr = TestInstFilter.GetXFilter("TSTEST-REQ", False) Debug.Print "--------------------------------------" Debug.Print "Inclusive is False:" Debug.Print aStr Dim aList As List, ListMember As Variant, tmpinstance As TSTest Set aList = testInstanceF.NewList(TestInstFilter.Text) For Each ListMember In aList Set tmpinstance = ListMember Debug.Print tmpinstance.name Next ' [1] Test_1 ' [1] Test_3 ' [2] Test_1 ' ' Now use the same criteria, but set the "Inclusive" argument ' of SetXFilter to False. ' The filter now means: Get all the test instances of the ' test set that do NOT cover the specified requirement. TestInstFilter.SetXFilter "TSTEST-REQ", False, xFilter.Text Debug.Print "--------------------------------------" Debug.Print "TestInstFilter.Text:" Debug.Print TestInstFilter.Text Debug.Print Debug.Print "--------------------------------------" aStr = TestInstFilter.GetXFilter("TSTEST-REQ", True) Debug.Print "Inclusive is True:" Debug.Print aStr aStr = TestInstFilter.GetXFilter("TSTEST-REQ", False) Debug.Print "--------------------------------------" Debug.Print "Inclusive is False:" Debug.Print aStr Set aList = testInstanceF.NewList(TestInstFilter.Text) For Each ListMember In aList Set tmpinstance = ListMember Debug.Print tmpinstance.name Next ' [1] Test_2 ' [1] Test_4 ' [2] Test_4 Debug.Print "--------------------------------------" aStr = TestInstFilter.GetXFilter("TSTEST-REQ", True) Debug.Print "Inclusive is True:" Debug.Print aStr ' Note: 'Using the XFilter property (in ITDFilter interface) is equivalent 'to calling SetXFilter with the value TRUE for the parameter InIds. ' ' To get all tests that do NOT have instances in test set that begin with ' MyTestSet (negative filter): ' 1. Get TDFilter object from TestFactory. ' 2. Call (remember it's a pseudo code) SetXFilter with the parameters ' "TEST-TESTSET",FALSE, and text representation of the filter test ' set name = MyTestSet*. Exit Sub RQTest_Err: ErrHandler err, "Req_TestInstance_Coverage", err.Description End Sub