How to remove Custom Properties from a SoapUI Test

2020-03-21 10:12发布

问题:

I have created some list of properties under the TestCase. For example look at the following screenshot.

I tried to remove Testcase_Property property through the following groovy script teststep:

testRunner.testCase.testSuite.removeProperty( "Testcase_Property" );

when I reload the project, the Testcase_Property property is still exist in the Custom Properties tab when I click on the Test case name.

Anyone suggest me what the correct script to remove the custom properties in SoapUI.

Thanks
Karunagara Pandi

回答1:

you can also use the following:

data = context.testCase.getTestStepByName("Test Case Name");

String[] propToRemove = new String[data.getPropertyCount()];
propToRemove = data.getPropertyNames();
for ( int i = 0 ; i < propToRemove.size(); i++ ){
    data.removeProperty( propToRemove[i] );
}

Hope this helps. Now you can remove more than one prop.



回答2:

Finally I got the answers for removing Project, Testsuite and Testcase custom properties. Here are the scripts.

testRunner.testCase.testSuite.project.removeProperty( "Project_Level_Property" );
testRunner.testCase.testSuite.removeProperty( "Testsuite_Property" );
testRunner.testCase.removeProperty( "Testcase_Property" );

If any other way is there, please let me know friends.



回答3:

Manual solution: use "Save Properties" and "Load Properties" from SoapUI

  1. export the properties to a text file, e.g. customprop.txt
  2. edit the file and delete the unwanted properties
  3. import the file back into your soapUI project
  4. in the "load properties" dialog check the option to "delete remaining"

Then the existing properties will be cleared out and replaced with your customprop.txt



回答4:

Just for completeness:

Another quick but dirty and dangerous way is to modify the soapui-project.xml and remove the property nodes with a text editor. Be aware that you can break your whole project if you do something wrong! You should create a copy of your soapui-project.xml and do the following steps:

  1. Set the values of the Properties you want to delete to deleteMe
  2. Search for the string deleteMe in your soapui-project.xml
  3. Delete the properties:

<con:property><con:name>name</con:name><con:value>deleteMe</con:value></con:property>