def createTestSuite(self, filePath, tagList = None): if self.isInvalidPath(filePath): print 'filePath' print 'Error: TBTAFOrchestrator.createTestSuite' else: _discoverer = TBTAFDiscoverer() testCaseList = _discoverer.LoadTests(filePath) testSuiteID = 'testSuiteID_01' if tagList is None: _testSuite = TBTestSuite(TBTAFTestSuiteType.NORMAL, testSuiteID) _testSuite.addTestCaseList(testCaseList) print 'Test ', testSuiteID, ' loaded from: ', filePath print 'Test suite created with ', len(_testSuite.getTestCases()), ' test cases' return _testSuite else: if self.isInvalidList(tagList): print 'tagList' print 'Error: TBTAFOrchestrator.createTestSuite' return else: _smartTestSuite = TBSmartTestSuite(testSuiteID) _smartTestSuite.addTestCaseList(testCaseList) filteredTestCases = _smartTestSuite.getTestCasesByTags(tagList, TBTAFFilterType.IN) _smartTestSuite.clearTestCaseList() _smartTestSuite.addTestCaseList(filteredTestCases) print 'Test ', testSuiteID, ' loaded from: ', filePath print 'Smart test suite created with ', len(_smartTestSuite.getTestCases()), ' test cases' return _smartTestSuite
def getTestCasesByTags(self,targetTags,queryFilter=None): ''' Method to obtain the tests that contain at least one of the given tags on the input list ''' dataSet = TBTestSuite.getTestCases(self) resultTestCases = [] #Check if the base data set is not None if dataSet is not None and targetTags is not None: #Iterate for each tag for targetTag in targetTags: for candidateTest in dataSet: #Fetch the test metadata testMetadata = candidateTest.getTestMetadata() if testMetadata is not None: testTags = testMetadata.getTags() if self.appendTestCase(testTags, targetTag, queryFilter): #There is a tag match, however we need to confirm if it has not been added yet to the result set if candidateTest not in resultTestCases: resultTestCases.append(candidateTest) return resultTestCases