Forum Discussion

livevox084's avatar
livevox084
Occasional Contributor
10 years ago

Facing Challenges in using Groovy DataSource on Ready API?

Hi All,

I am trying to setup Groovy DataSource on Ready API.

 

My Assumption is:

When i  run my groovy script(available in groovy editor in DataSource ) the data should populate data in data log.

 

My Script essentially contains a Map with key, value of string type.

Script:

 

//Boundary Values Needs to Be Populated Via Script
	//minVal 				--Pass
	//MaxVal 				--Pass
	//(maxVal-minVal)/2)  	--Pass
	//(minVal-1)  			--Fail
	//(maxVal+1)  			--Fail

	def dataMap =[:]
	def dataKey
	def expResult
//Reading Min and Max Values From TestCase Properties
	def minVal = context.expand( '${#TestCase#minVal}' )
	def maxVal = context.expand( '${#TestCase#maxVal}' )
 	def avgVal=((maxVal.toInteger()-minVal.toInteger())/2)
 	def lowVal=((minVal.toInteger())-1)
 	def highVal=((maxVal.toInteger())+1)
//Adding Five Boundary Values 
	dataMap<<[(""+minVal): "success"]
	dataMap<<[(""+maxVal): "success"]
	dataMap<<[(""+avgVal): "success"]
	dataMap<<[(""+lowVal): "failure"]
	dataMap<<[(""+highVal):"failure"]
	
	//log.info dataMap


dataMap.each{
	dataKey=it.key
	expResult=it.value
	//Adding Map Elements to 'dataKey' and 'expResult' properties
	result['dataKey']=it.key
	result['expResult']=it.value


}

Groovy Data Source ScreenShot.png

 

After running the Script the Data Log is always updating with only last key ,value pair of Map.

And It is not listing map elements one by one .

Not sure where i am doing mistake?

Anybody can help in this?

 

Thanks,

Rajendra Prasad Reddy

 

 

No RepliesBe the first to reply