Forum Discussion

zsousa's avatar
8 years ago

check if custom property exists

Hi All, I have a test case that has several custom properties, is there a way to check if a specific custom property exists ?
  • zen_paul's avatar
    8 years ago

    Yes, here is a sample of code using a GroovyScript teststep and the testRunner variable,


    hasProperty is the method to find out if the property exists.

    This code sees if a property exists and deletes the property if it is found, so that it can be set by another groovy script.


    def tc = testRunner.getTestCase()
    if (tc.hasProperty("myCustomProperty")) tc.removeProperty( "myCustomProperty" )


    Hope it helps