header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
November 22, 2008, 01:21:41 am
Username: Password:
Login with username, password and session length

Forgot your password?
 
Groovy Datasource
Welcome, Guest. Please login or register.
November 22, 2008, 01:21:41 am
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  Groovy Datasource
« previous next »
Pages: [1] Print
Author Topic: Groovy Datasource  (Read 549 times)
Jon
Newbie
*
Posts: 20


« on: June 02, 2008, 07:02:29 pm »

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:

Code:
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:

Code:
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!
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #1 on: June 03, 2008, 03:05:34 pm »

Hi!

I'm not sure if you really need a Groovy DataSource for this, how about the following:

1) an initial Script that writes the first value to the context
2-X) any numbers of steps that use the value
last) a script that increases the value in the context and loops back to 2 if the limit hasn't been reached

would that work?

regards,

/Ole
eviware.com
Logged
Jon
Newbie
*
Posts: 20


« Reply #2 on: June 03, 2008, 03:08:57 pm »

Hey Ole,

That's a great idea, one which I'd thought of using at one point, but I couldn't figure out how to go back to a given step.  The conditional goto uses xpath and the datasource loop requires a datasource to increment.

Cheers!
Jon
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #3 on: June 03, 2008, 03:12:29 pm »

Hi Jon,

you can use

testRunner.gotoStepByName( ... )

which will transfer execution to the named step when the script finishes (not at once!)

regards,

/Ole
eviware.com
Logged
Jon
Newbie
*
Posts: 20


« Reply #4 on: June 03, 2008, 03:38:24 pm »

Cool!  I will give that a try, thanks!
Logged
Jon
Newbie
*
Posts: 20


« Reply #5 on: June 09, 2008, 07:05:38 pm »

Hey Ole,

Just wanted to say thank you... these suggestions worked out quite well in the end.  Nice to not have to use an external file for everything.  Smiley

Cheers!
Logged
omatzura
Administrator
Hero Member
*****
Posts: 1,425


« Reply #6 on: June 09, 2008, 09:23:31 pm »

Great! Thanks for following up!

regards,

/Ole
eviware.com
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header