cancel
Showing results for 
Search instead for 
Did you mean: 

Clean TC and TS propertis when saving project

SOLVED
Highlighted
Contributor

Clean TC and TS propertis when saving project

I am using the ReadyAPI and GIT. I wnat to have all the properties visible to me during developing the tests = I dont want to enable the new settins in preferences (to clean properties after test case run).

Now a tons os tests are created.. there are some properties used in test case level or test suite level.. 

When commited in to GIT, next time the values will be changed.. So in next commit will be visible in each TC update..

How to solve the problem:

 

Enable script when project saving.. 

def project = testRunner.testCase.testSuite.project

log.info "start"
for ( t in testRunner.testCase.testSuite.project.getTestSuiteList() ) {
	log.info " -s " + t.name 
	//log.info "-suite propertis count: " + t.getPropertyCount()
	
	for ( c in t.getTestCaseList() ) {
		log.info " --tc " + c.name
		//log.info " -- suite propertis count: " + c.getPropertyCount()
		
		if (c.getPropertyCount() > 0) {
			
			for( n in c.propertyNames ){
				log.info " --- tcp " + n + " value: " + c.getPropertyValue(n)
				if (n == "countDown") {
					c.setPropertyValue( n, '0')		
					}  					
					else {
						c.setPropertyValue( n, '')
						}
				}
			}	   	
		}
	}

log.info "done"

 

I am not the groovy expert.. just validator.. But I spend searching of the solution on internet half of a day.. So I hope.. I can save some energy to the others.

Because even here were some scripts foundable.. but with errors.. 

This script works. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Contributor

Re: Clean TC and TS propertis when saving project

in the project save script remove line with "def project".. 

and enable save/load scripts in ReadyAPI preferences

View solution in original post

Highlighted
Contributor

Re: Clean TC and TS propertis when saving project

Here is updated script, you can even filter the propertie name, when for example insluce # prefix in the name.. so skip the clening.. 

 

Here is full script for project = will not work under groovy script test step.. 

log.info "*********** SAVE PROJECT script ***********";
log.info "Cleaning the properties values - start"
for ( t in project.getTestSuiteList() ) {
	log.info " -s " + t.name 
	//log.info "-suite propertis count: " + t.getPropertyCount()
	
	for ( c in t.getTestCaseList() ) {
		log.info " --tc " + c.name
		//log.info " -- suite propertis count: " + c.getPropertyCount()
		
		if (c.getPropertyCount() > 0) {
			
			for( n in c.propertyNames ){
				log.info " --- tcp " + n + " value: " + c.getPropertyValue(n)
				if (n.substring(0,1) != "#"){
					if (n == "countDown") {
						c.setPropertyValue( n, '0')		
						}  					
					else {
						c.setPropertyValue( n, '')
						}
					}
				else
					{log.info " ---- cleaning skipped"}				
				}
			}	   	
		}
	}

log.info "Cleaning the properties values - finished"

View solution in original post

3 REPLIES 3
Highlighted
Contributor

Re: Clean TC and TS propertis when saving project

in the project save script remove line with "def project".. 

and enable save/load scripts in ReadyAPI preferences

View solution in original post

Highlighted
Community Hero

Re: Clean TC and TS propertis when saving project

@vikititor,

Cheers for that.....this looks handy!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

Re: Clean TC and TS propertis when saving project

Here is updated script, you can even filter the propertie name, when for example insluce # prefix in the name.. so skip the clening.. 

 

Here is full script for project = will not work under groovy script test step.. 

log.info "*********** SAVE PROJECT script ***********";
log.info "Cleaning the properties values - start"
for ( t in project.getTestSuiteList() ) {
	log.info " -s " + t.name 
	//log.info "-suite propertis count: " + t.getPropertyCount()
	
	for ( c in t.getTestCaseList() ) {
		log.info " --tc " + c.name
		//log.info " -- suite propertis count: " + c.getPropertyCount()
		
		if (c.getPropertyCount() > 0) {
			
			for( n in c.propertyNames ){
				log.info " --- tcp " + n + " value: " + c.getPropertyValue(n)
				if (n.substring(0,1) != "#"){
					if (n == "countDown") {
						c.setPropertyValue( n, '0')		
						}  					
					else {
						c.setPropertyValue( n, '')
						}
					}
				else
					{log.info " ---- cleaning skipped"}				
				}
			}	   	
		}
	}

log.info "Cleaning the properties values - finished"

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors