木吟

导航

移除project,testsuite,testcase级别所有的custom properties

// Remove all custom properties on Project level. If removed, custom properties cannnot be injected to Project in new environment except default env
def removeProjectProperties(){
    def propertyNames = testRunner.testCase.testSuite.project.getPropertyNames()    
    for (int i=0; i<propertyNames.size();i++){
            testRunner.testCase.testSuite.project.removeProperty(propertyNames[i])
    }            
}

// Remove all custom properties on TestSuite level
def removeTestSuiteProperties(){
    def testSuiteList = testRunner.testCase.testSuite.project.getTestSuites()
    def testSuiteName    
    for (testSuite in testSuiteList){
        testSuiteName = testSuite.toString().split('=')[0]    
        def ts = testRunner.testCase.testSuite.project.getTestSuiteByName(testSuiteName)
        def propertyNames = ts.getPropertyNames()
        for (int i=0; i<propertyNames.size();i++){
                ts.removeProperty(propertyNames[i])
        }    
    }        
}

// Remove all custom properties on TestCase level
def removeTestCaseProperties(){
    def testSuiteList = testRunner.testCase.testSuite.project.getTestSuites()
    def testSuiteName    
    for (testSuite in testSuiteList){
        testSuiteName = testSuite.toString().split('=')[0]    
        def testCaseList = testRunner.testCase.testSuite.project.getTestSuiteByName(testSuiteName).getTestCases()
        def testCaseName        
        for (testCase in testCaseList){            
            testCaseName = testCase.toString().split('=')[0]                
            def tc = testRunner.testCase.testSuite.project.getTestSuiteByName(testSuiteName).getTestCaseByName(testCaseName)
            def propertyNames = tc.getPropertyNames()
            for (int i=0; i<propertyNames.size();i++){
                    tc.removeProperty(propertyNames[i])
            }    
        }        
    }    
}

 

posted on 2015-12-03 17:04  木吟  阅读(484)  评论(0)    收藏  举报