Grant Edwards
Grant Edwards

Reputation: 37

Clear all project property values in SoapUI using groovy script

Within soapUI, I'm using multiple groovy scripts to write values to the Project Level so that multiple test suites can pull data during a test run. At the end of the run, I would like to use a Groovy script that removes all the values (not the placeholders) from project properties. I tried using the clearPropertyValues(), but get an error. I do not think I'm setting up my script correctly. Any help is appreciated.

Upvotes: 2

Views: 4165

Answers (1)

albciff
albciff

Reputation: 18507

I suppose that you want to remove the custom properties values from your project, keeping the property names. IMO the correct place to do so is using groovy in the tearDown script of your project, so you can go to navigator window on the SOAPUI and double click in your project, it opens the project config pop up, then select the testSuites tab and click on testDown script, there you can place the follow groovy code which set the properties of your project to empty string (to keep the placeholders):

// for each property in the project level 
project.getPropertyNames().each{ propName ->
    log.info "remove prop: $propName"
    // set it's value as an empty string
    project.setPropertyValue(propName,'')
}

Note that tearDown script will be executed each time all your testSuites are finish from project execution.

enter image description here

Hope it helps,

Upvotes: 4

Related Questions