Forum Discussion

kahmaui808's avatar
kahmaui808
Occasional Contributor
8 years ago

How Clear TestStep Values using TearDown Script

I have two projects. Project 1 is encrypted and has all the values for Project 2.   Project 2 runs and retrieves the values from Project 1, executes the tests and then I need Project 2 to get rid o...
  • Radford's avatar
    8 years ago

    I'm not sure if this is any help, but...

     

    [Edit: Amended script after comments below]

     

    I took a look at this and came up with the following project teardown script:

     

    project.getTestSuites().each {testSuiteName, testSuite ->
    	log.info('Test Suite: ' + testSuiteName)
    	testSuite.getTestCases().each{testCaseName, testCase ->
    		log.info('Test Case: ' + testCaseName)
    		testCase.getTestSteps().each{testStepName, testStep  ->
    			log.info('Test Step: ' + testStepName)
    			if(testStep in com.eviware.soapui.model.TestPropertyHolder){
    				testStep.getProperties().each{propName, prop ->
    					if(!prop.isReadOnly()){
    						// You may want to only remove properties based on property name here...
    						log.info('Initial: ' + propName + ' = ' + prop.getValue() )
    						prop.setValue('')
    						log.info('Removal: ' + propName + ' = ' + prop.getValue() )
    					}
    				}
    			}
    		}
    	}
    }pre>

     

    Interestingly I also saw that while some were removed with some properties not marked as read only they would not be removed, no error was raised either.

     

    As a side note, this script is quite brutal in the way it attempts to remove all properties including all the ones that configure the test step, did you really want to do this or was it specific properties you wanted to remove?