Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Custom Properties from a SoapUI TestCase using Groovy?

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

SoapUI Pro - Testcase Properties

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

like image 911
Karunagara Pandi Avatar asked Jul 31 '14 05:07

Karunagara Pandi


People also ask

How do I set property in SoapUI using groovy?

In the groovy script, add the following script. This script will assign a string text to the property and then it will show in the log after executing the test case. Once written the above script in the editor, double-click on the test case name step. and the see the results in the script log tab.

How do I change properties in SoapUI?

Both global and system properties can be set directly from the command-line when running any of the SoapUI bat/sh files; -Dproperty.name=value sets a system property and -Gproperty.name=value sets a Global Property.

How do I see custom properties in SoapUI?

Test suite properties appear when click on the respective test suite name under the project. To add custom properties as needed, click on custom properties tab and click on the '+' sign under it. Test case properties are accessible within the test case.

How do I use groovy in SoapUI?

Call One Groovy Class from Another Groovy Class To create a class in SoapUI, right-click on TestStep and choose Groovy Script to open the editor. Save the class as MyClass and then write the following code, as shown below. Click on the run button to execute the Groovy script.


1 Answers

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.

like image 114
Rami Sharaiyri Avatar answered Oct 11 '22 17:10

Rami Sharaiyri