Forum Discussion

rodgersh's avatar
rodgersh
Occasional Contributor
13 years ago

How do I remove a global property from a Groovy script?

I have a Groovy setup script that programmatically creates/sets global properties. In my associated Groovy tear down script I want to remove/delete those same global properties (rather than just set them to null or an empty string).

How do I do this?

I have tried context.removeProperty( propertyName ) which did nothing (property and its value set in the setup script are still there).

I also tried PropertyExpansionUtils.GlobalPropertyExpansionContext.removeProperty( propertyName ) and get a runtime script error that states:


Wed Sep 26 13:28:25 MST 2012:ERROR:groovy.lang.MissingMethodException: No signature of method: static com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils$GlobalPropertyExpansionContext.removeProperty() is applicable for argument types: (java.lang.String) values: [PROPERTY_NAME]
Possible solutions: removeProperty(java.lang.String), getProperty(java.lang.String)

What am I doing wrong?

Thanks -

Hugh

4 Replies

  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Hi Hugh,

    Can you post some of the code that creates your global properties please?

    Kind regards,
    Tim
  • Hi,

    Try this Code .This may help you

    com.eviware.soapui.SoapUI.globalProperties.removeProperty( "propertyName")
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    are you sure about:

    context.removeProperty( "propertyName") ?

    when I do this and then call context.getProperty( "propertyName") result is null
  • Jenny2L's avatar
    Jenny2L
    Not applicable
    How about remove all created properties in whole test suite at one time? Not only global, but also private properties in each test case.
    Appreciate if any feedback.