How to remove (not clear) test case properties from SaveScript
Whenever I save my project, I want to delete all the testcase properties, otherwise I end up with many orphaned properties. I've added this code into the save script hook
for ( testSuite in project.getTestSuiteList() ) {
for ( testCase in testSuite.getTestCaseList() ) {
if (testCase.getPropertyCount() > 0) {
for( propertyName in testCase.propertyNames ){
testCase.setPropertyValue(propertyName, '');
}
}
}
}
which clears all the properties. However if there is a property which is no longer being used, that property remains. Instead I want to delete them all.
I found this, but it is from 16 years ago and the link to docs no longer works.
Remove Properties of TestCase from Groovy. | SmartBear Community
It also talks about using the testRunner, but as far as I can tell, the testRunner isn't available in the saveScript, as no tests are being run...
Below script should help:
project.testSuiteList.each { suit -> suit.testCaseList.each { kase -> kase.propertyNames.each { kase.removeProperty(it) } } }