Jon
16 years agoContributor
Groovy Datasource
Hi!
Trying to use a groovy datasource to generate some test values (to eliminate a spreadsheet containing just a column of numbers).
I need to iterate over that column, changing the values each time an outer loop increments.
What I have is this: a groovy datasource with a single property defined. NExt, I have this script which takes two TestCase properties as the base from which to compute the list of values:
The startNetPort is set to 1000 and numNetPortsPerTS is set to 10.
However, running this only gives me the same value (1009). As well, trying to access the property, like so:
from another test step (groovy script) results in:
Mon Jun 02 13:53:51 EDT 2008:ERROR:java.lang.NumberFormatException: For input string: ""
The notes for the groovy datasource didn't help me out much so I'm hoping you can shed some light.
Cheers!
Trying to use a groovy datasource to generate some test values (to eliminate a spreadsheet containing just a column of numbers).
I need to iterate over that column, changing the values each time an outer loop increments.
What I have is this: a groovy datasource with a single property defined. NExt, I have this script which takes two TestCase properties as the base from which to compute the list of values:
def numNetPortsPerTSStr = context.expand( '${#TestCase#numNetPortsPerTS}' )
def startNetPortStr = context.expand( '${#TestCase#startNetPort}' )
def numNetPortsPerTS = Integer.parseInt(numNetPortsPerTSStr)
def startNetPort = Integer.parseInt(startNetPortStr)
def i = 0
while (i < numNetPortsPerTS)
{
result.netPort = startNetPort + i
i++
}
The startNetPort is set to 1000 and numNetPortsPerTS is set to 10.
However, running this only gives me the same value (1009). As well, trying to access the property, like so:
def netPortStr = context.expand( '${Net Port Datasource#netPort}' )
println "netPortStr:"+netPortStr
from another test step (groovy script) results in:
Mon Jun 02 13:53:51 EDT 2008:ERROR:java.lang.NumberFormatException: For input string: ""
The notes for the groovy datasource didn't help me out much so I'm hoping you can shed some light.
Cheers!