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

时间:2022-07-12 05:01:40
// 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])
}
}
}
}