Esempio n. 1
0
	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	
Esempio n. 2
0
def invalidInputResumeExecution():
    ejecutor = TBTAFExecutor()
    suite = TBTestSuite(1,'Sample test 4')
    for i in range(3):
        newTest = TBTAFSampleTest()
        suite.addTestCase(newTest)
    ejecutor.resumeExecution(suite)
Esempio n. 3
0
def invalidResume():
    tbTestSuite = TBTestSuite(1,'Sample test 2')
    for i in range(3):
        newTest = TBTAFSampleTest()
        tbTestSuite.addTestCase(newTest)

    executionTBTestSuite = ExecutionTBTestSuite(tbTestSuite)
    executionTBTestSuite.resume()
Esempio n. 4
0
def validGetBySuiteAndInit():
    tbTestSuite = TBTestSuite(1,'Sample test')
    for i in range(3):
        newTest = TBTAFSampleTest()
        tbTestSuite.addTestCase(newTest)

    executionTBTestSuite = ExecutionTBTestSuite.getBySuite(tbTestSuite)
    if executionTBTestSuite is None:
        executionTBTestSuite = ExecutionTBTestSuite(tbTestSuite)
Esempio n. 5
0
def validInputAbortExecution():
    ejecutor = TBTAFExecutor()
    suite = TBTestSuite(1,'Sample test 2')
    for i in range(3):
        newTest = TBTAFSampleTest()
        suite.addTestCase(newTest)
    ejecutor.executeTests(suite)
    time.sleep(10)
    ejecutor.abortExecution(suite)
    ejecutor.getStatus(suite)
Esempio n. 6
0
def invalidExecute():
    tbTestSuite = TBTestSuite(1,'Sample test 2')
    for i in range(3):
        newTest = TBTAFSampleTest()
        tbTestSuite.addTestCase(newTest)

    executionTBTestSuite = ExecutionTBTestSuite(tbTestSuite)
    executionTBTestSuite.execute()
    time.sleep(1)
    executionTBTestSuite.execute()
Esempio n. 7
0
def sample_run():
    ejecutor = TBTAFExecutor()
    suite = TBTestSuite(1,'A')
    for i in range(5):
        newTest = TBTAFSampleTest()
        suite.addTestCase(newTest)
    ejecutor.executeTests(suite)
    
    while True:
        ejecutor.getStatus(suite)
        time.sleep(10)
Esempio n. 8
0
def validSetAndGetSuiteResult():
    tbTestSuite = TBTestSuite(1,'Sample test 1')
    for i in range(3):
        newTest = TBTAFSampleTest()
        tbTestSuite.addTestCase(newTest)

    temp = tbTestSuite.getSuiteResult()
    
    tbtafExecutionStatus = TBTAFExecutionStatus()
    tbtafExecutionStatus.setSuiteResult(temp)
    result = tbtafExecutionStatus.getSuiteResult()
    if result != temp:
        raise Exception('The value returned is not the same that was set')
Esempio n. 9
0
def validInputExecuteTests():
    ejecutor = TBTAFExecutor()
    suite = TBTestSuite(1,'Sample test')
    for i in range(3):
        newTest = TBTAFSampleTest()
        suite.addTestCase(newTest)
    ejecutor.executeTests(suite)
    
    waitingComplete = True
    while waitingComplete:
        result = ejecutor.getStatus(suite)
        time.sleep(5)
        waitingComplete = result.getExecutionStatusType() != TBTAFExecutionStatusType.COMPLETED
Esempio n. 10
0
def validExecute():
    tbTestSuite = TBTestSuite(1,'Sample test 1')
    for i in range(3):
        newTest = TBTAFSampleTest()
        tbTestSuite.addTestCase(newTest)

    executionTBTestSuite = ExecutionTBTestSuite(tbTestSuite)
    executionTBTestSuite.execute()
    
    waitingComplete = True
    while waitingComplete:
        result = executionTBTestSuite.getStatus()
        time.sleep(5)
        waitingComplete = result != TBTAFExecutionStatusType.COMPLETED
Esempio n. 11
0
 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
Esempio n. 12
0
 def getSuiteResult(self,tags,queryFilter=None):
     '''
     Method to obtain the TBTAF result based on a specific set of tags
     '''
     TBTestSuite.getSuiteResult(self)
     #Obtain the test cases based on the tag query
     selectedTestCases = self.getTestCases(tags,queryFilter)
     
     candidateVerdict = TBTAFVerdictType.INCONCLUSIVE
     startTimestamp = datetime.datetime.max
     endTimestamp = datetime.datetime.min
     passTests = 0
     inconclusiveTests = 0
     failedTests = 0
     
     if selectedTestCases is not None and len(selectedTestCases) > 0:
         
         for suiteTestCase in selectedTestCases:
             #Check if the trace is not null
             currentResult = suiteTestCase.getResult()
             
             if currentResult is not None:
                 #Check the test verdict
                 testVerdict = currentResult.getVerdict()
                 if testVerdict == TBTAFVerdictType.INCONCLUSIVE:
                     inconclusiveTests = inconclusiveTests + 1
                 elif testVerdict == TBTAFVerdictType.FAIL:
                     failedTests = failedTests + 1
                 elif testVerdict == TBTAFVerdictType.PASS:
                     passTests = passTests + 1
                 #Calculate the timestamps
                 if currentResult.getStartTimestamp() is not None:
                     if startTimestamp > currentResult.getStartTimestamp():
                         startTimestamp = currentResult.getStartTimestamp()
                     
                 if currentResult.getEndTimestamp() is not None:
                     if endTimestamp < currentResult.getEndTimestamp():
                         endTimestamp = currentResult.getEndTimestamp()
                 
             else:
                 inconclusiveTests = inconclusiveTests + 1
                 
     #With the gathered data we create the result of the overall suite
     # First the verdict
     if len(selectedTestCases) == passTests and len(selectedTestCases) > 0:
         candidateVerdict = TBTAFVerdictType.PASS
     elif failedTests is not 0:
         candidateVerdict = TBTAFVerdictType.FAIL
     else:
         candidateVerdict = TBTAFVerdictType.INCONCLUSIVE
     
     #Then create the result instance for the suite
     suiteResult = TBTAFResult(candidateVerdict,self.suiteID)
     suiteResult.setStartTimestamp(startTimestamp)
     suiteResult.setEndTimestamp(endTimestamp)
     #Set the summary results at the suite level
     suiteResult.setInconclusiveTests(inconclusiveTests)
     suiteResult.setFailedTests(failedTests)
     suiteResult.setPassTests(passTests)
     
     return suiteResult