Forum Discussion

mpw83's avatar
mpw83
Contributor
5 years ago
Solved

Remove all the properties starts with given value

I found that I can use the following groovy script line to remove the given property 

testRunner.testCase.removeProperty('ScheduleID');

In my test case, I have properties like 'ScheduleID0' , 'ScheduleID1', 'ScheduleID2' ..etc 

Is there any script that I can use in my TearDown Script to remove all the test properties that I mentioned above which starts with 'ScheduleID'?

Help much appreciated. Thanks 

  • Hi mpw83 ,

     

    You can use more of groovy to find solution of your problem, first count the number of properties stored under Test Case custom properties and then delete the selected properties, refer below code for reference:

     

    def targetTestCase = testRunner.testCase;
    def propList = targetTestCase.getPropertyNames()
    propList.each{
    	if(it.contains("ScheduleID")){
    		targetTestCase.removeProperty(it);
    	}
    	else{
    		//Do nothing
    	}
    }
    

2 Replies

  • Hi mpw83 ,

     

    You can use more of groovy to find solution of your problem, first count the number of properties stored under Test Case custom properties and then delete the selected properties, refer below code for reference:

     

    def targetTestCase = testRunner.testCase;
    def propList = targetTestCase.getPropertyNames()
    propList.each{
    	if(it.contains("ScheduleID")){
    		targetTestCase.removeProperty(it);
    	}
    	else{
    		//Do nothing
    	}
    }