Delete Project Level Properties With Specific Name After Execution
Hi,
Bit embaressed I can't fix this myself :(
I have some project level properties I create after running a setup testsuite to grab some GUIDS out of the database for later use in the project and I'd like to delete these project level properties after each execution run.
I have a number of project level properties and I only want to delete ones containing a certain string in the property name, so I was thinking add a script to the project teardown.
I almost found exactly what I needed via this link
In the linked page HimanshuTayal 's code reads as follows (which gets added to the testCase teardown script):
def targetTestCase = testRunner.testCase; def propList = targetTestCase.getPropertyNames() propList.each{ if(it.contains("ScheduleID")){ targetTestCase.removeProperty(it); } else{ //Do nothing } }
HOWEVER - the above is to delete testcase level properties rather than project level properties - so I altered it to the following (added it to the Project teardown script) thinking this would work
def targetTestCase = testRunner.testCase.testSuite.project; def propList = targetTestCase.getPropertyNames() propList.each{ if(it.contains("ScheduleID")){ targetTestCase.removeProperty(it); } else{ //Do nothing } }
But I got the following error response
Tue Jun 18 10:57:20 BST 2019: ERROR: com.eviware.soapui.support.scripting.ScriptException: Error in TearDown Script of Eehatevs
Can anyone see what I'm doing wrong? well - I'm sure everyone can see what I'm doing wrong - but I cant. :)
I checked around and to navigate to the project level - (in the testRunner line) and that appears how to drill to the project level? (e.g. testRunner.testCase.testSuite.project)??
Cheers!
richie
Hope below helps for the same.
//Add the property (exact) names to be removed in below statement, comma separated if more than one def listToRemove = ['ScheduleID'] listToRemove.findAll { it in project.propertyNames }.each { project.removeProperty(it)}