Forum Discussion

krogold's avatar
krogold
Regular Contributor
8 years ago

Problems deleting custom properties from a test case

Hello,

I'm trying to remove properties from a test case. I found the following code to do so and customized it but it doesn't work:

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] );
}

It does not work because I don't have any removeProperty method available ?! The only one I have is removePropertyChangeListener.

 

How can I use this method ? I tried to use the result of data.getPropertyAt(<myIndex>) but the type is not correct.

How can I get a PropertyChangeListener type from my testCase data ?

 

any help welcome  :(

  • Thank you for posting to our Community Forum.

     

    Here is a script (created in ReadyAPI 2.1) that deletes all testcase properties.

     

    propertyNames = context.getTestCase().getPropertyNames()
    
    for(propertyName in propertyNames){
    	context.getTestCase().removeProperty(propertyName)
    }

    Let me know if you have any questions/concerns.

  • StevenColon's avatar
    StevenColon
    SmartBear Alumni (Retired)

    Thank you for posting to our Community Forum.

     

    Here is a script (created in ReadyAPI 2.1) that deletes all testcase properties.

     

    propertyNames = context.getTestCase().getPropertyNames()
    
    for(propertyName in propertyNames){
    	context.getTestCase().removeProperty(propertyName)
    }

    Let me know if you have any questions/concerns.

    • krogold's avatar
      krogold
      Regular Contributor

      !! very nice one !! :smileyvery-happy:

      thank you, I had a solution with an external file but this one is much more suitable