Changeset 2304

Show
Ignore:
Timestamp:
06/14/07 11:07:16 (1 year ago)
Author:
edunne
Message:

TestCaseManagementPlugin:

added some exception handling to the validate test cases method in the properties file. An uncaught exception could occur if the configuration was wrong in the TRAC config file for the either the repository_dir path or the subversionpathtotestcases path.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • testcasemanagementplugin/trunk/testManagementPlugin/properties.py

    r2283 r2304  
    135135    def validateTestCases( self, component, req ): 
    136136     
    137         tempTestCaseList = [] 
    138         errors = [] 
    139          
    140         projTemplates = self.getTemplates(component, req ) 
    141          
    142         if projTemplates != None :          
    143             for name in projTemplates.getTemplateNames() :  
    144                 name = name.encode('ascii', 'ignore') 
    145                 testIds = projTemplates.getTestsForTemplate( name ) 
    146                 if testIds != None :  
    147                     for id in testIds :  
    148                         if id not in tempTestCaseList : 
    149                             tempTestCaseList.append( id ) 
    150  
    151             allTestcases, errors = self.getTestCases( component, req ) #fetch the testcases... 
    152          
    153             if allTestcases == None :  
    154                 return False, None 
    155              
    156             for testId in tempTestCaseList: 
    157                 if testId in allTestcases :  
    158                     continue 
    159                 else: 
    160                     errors.append( "The test: " + testId + ", in the testtemplates.xml file cannont be matched with a real test case" ) 
    161         else: 
    162             #ok if no testtemplates file exists we should definately flag that.  However rather than bail we could also still validate  
    163             #the existing testcases to make sure they are well formed. 
    164             allTestcases, errors = self.properties.getTestCases( self, req ) #fetch the testcases... 
    165              
    166             #append the error message saying testtemplates.xml doesn't exist, then exit. 
    167             errors.append( "No file called testtemplates.xml file found.  This is the file necessary for grouping testcases into predefined test scripts...like a smoke test" ) 
    168          
     137        try: 
     138            tempTestCaseList = [] 
     139            errors = [] 
     140             
     141            projTemplates = self.getTemplates(component, req ) 
     142             
     143            if projTemplates != None :          
     144                for name in projTemplates.getTemplateNames() :  
     145                    name = name.encode('ascii', 'ignore') 
     146                    testIds = projTemplates.getTestsForTemplate( name ) 
     147                    if testIds != None :  
     148                        for id in testIds :  
     149                            if id not in tempTestCaseList : 
     150                                tempTestCaseList.append( id ) 
     151     
     152                allTestcases, errors = self.getTestCases( component, req ) #fetch the testcases... 
     153             
     154                if allTestcases == None :  
     155                    return False, None 
     156                 
     157                for testId in tempTestCaseList: 
     158                    if testId in allTestcases :  
     159                        continue 
     160                    else: 
     161                        errors.append( "The test: " + testId + ", in the testtemplates.xml file cannont be matched with a real test case" ) 
     162            else: 
     163                #ok if no testtemplates file exists we should definately flag that.  However rather than bail we could also still validate  
     164                #the existing testcases to make sure they are well formed. 
     165                allTestcases, errors = self.properties.getTestCases( self, req ) #fetch the testcases... 
     166                 
     167                #append the error message saying testtemplates.xml doesn't exist, then exit. 
     168                errors.append( "No file called testtemplates.xml file found.  This is the file necessary for grouping testcases into predefined test scripts...like a smoke test" ) 
     169                 
     170        except Exception, ex: 
     171            errors.append( "An uspecified error occured...the most likely cause is either the path subversionpathtotestcases or repository_dir configuration values are set wrong in the trac.conf file.  Error message included hopefully it will be useful") 
     172            errors.append( "Exception was: " + str(ex) ) 
     173             
    169174        return errors 
    170175