Forum Discussion

skelkar's avatar
skelkar
Contributor
10 years ago

How to Clean custom properties after each execution run of a test case?

Hi,

 

I have a test case with multiple steps incuding properties step.

I want to delete all properties after scuessful execution.

 

Below code I copied in groovy script test step / test case tear down script but it is not working.

 

def map = testRunner.testCase.getProperties()
def t= map.each{
    key, value -> testRunner.testCase.removeProperty(value)
}

8 Replies

  • jkrier's avatar
    jkrier
    Regular Contributor

    I use this

     

    def props = testRunner.testCase.testSteps["myprops"]
    
    String[] props = new String[props.getPropertyCount()]
    aprops = props.getPropertyNames();
    
    for (int i=0;i<aprops.size();i++)
    {
        props.setPropertyValue(aprops[i],"")
    }

     

    • Sandyapitester's avatar
      Sandyapitester
      Frequent Contributor

      Above the script also not working

       

      def props = testRunner.testCase.testSteps["SProperty"]//(My property name)

      String[] props = new String[props.getPropertyCount()]
      aprops = props.getPropertyNames();

      for (int i=0;i<aprops.size();i++)
      {
      props.setPropertyValue(aprops[i],"")
      }

       

      correct me if u have any new update for this

      • nmrao's avatar
        nmrao
        Champion Level 3
        Are you in need of such script? If yes, not sure why it is repeated? Please clarify exact problem that are facing.