cancel
Showing results for 
Search instead for 
Did you mean: 

DataSource Inner/Outer Loop possibility

Contributor

DataSource Inner/Outer Loop possibility

Hi,
I have written a Test Case that requires me to have 2 DataSources (conveniently that is) which in traditional programming terms should be read via an inner/outer loop.

Therefore if I have 12 Records/Rows in Data Source 1 (read from an Excel File) and 6 Rows in Data Source 2 then there should be a SoapUI Request executed 72 times (12 x 6) with each combination of DS1 and DS2 selected.

Problem is that I cannot see a way to reset Data Source 2 to the FIRST Row when I move onto the 2nd Row of Data Source 1 (and obviously have just read Row 6 of DataSource 2). What happens is that Row 6 of DataSource 2 is continually used.

e.g. Test Steps

DataSource 1 (12 Records)
DataSource 2 (6 Records)
Create Request
DataSource Loop To DataSource 2
** Possibly some type of scrip reset option here for DataSource 2 
DataSource Loop To DataSource 1

Any Help appreciated.

Desmond.
10 REPLIES 10
Super Contributor

Re: DataSource Inner/Outer Loop possibility

Hi Desmond,

this will be fixed in the upcoming release, for now you will have to "finish" the inner datasource manually, please try the following groovy script:

def dataSourceStep = testRunner.testCase.testSteps["Innert DataSource"]
dataSourceStep.finish( testRunner, context )

Hope this helps!

regards,

/Ole
eviware.com
Contributor

Re: DataSource Inner/Outer Loop possibility

Hi Ole...

Worked a treat...Many thanks.....just surprised nobody has asked for this before !

Desmond.
Jon
Contributor

Re: DataSource Inner/Outer Loop possibility

omatzura wrote:

Hi Desmond,

this will be fixed in the upcoming release, for now you will have to "finish" the inner datasource manually, please try the following groovy script:

def dataSourceStep = testRunner.testCase.testSteps["Innert DataSource"]
dataSourceStep.finish( testRunner, context )

Hope this helps!

regards,

/Ole
eviware.com


I have a need to reset a datasource as well.  I need it to create an initial batch of objects, then need to recycle it later on for a continous loop of adding/removing (stress testing) a group containing all of the initially created objects.

As teststep 1, I have "Unit Datasource" defined to pull data from Excel and populate a bunch of property values.

I then, after my initial batch of object additions, have this as my groovy script:

def dataSourceStep = testRunner.testCase.testSteps["Unit DataSource"]
dataSourceStep.finish( testRunner, context )

Perhaps there's more code I need to add before/after those lines?  Anyway, the error I get when that step is reached:

Thu May 29 12:32:18 EDT 2008:ERROR:java.lang.NullPointerException: Cannot invoke method finish() on null object

What do I need to do?  I'm evaluating soapUI Pro - looks really promising for what we need to do - so I'm still figuring all this stuff out and am probably making all sorts of beginner mistakes.
Super Contributor

Re: DataSource Inner/Outer Loop possibility

Hi,

this error indicates that the dataSourceStep variable is null, it seems you have either misspelled the name of the Inner DataSource step, or are using an older release where you need to use testRunner.testCase.getTestStepByName( "..." ) instead!?

regards,

/Ole
eviware.com
Jon
Contributor

Re: DataSource Inner/Outer Loop possibility

If I use:


def dataSourceStep = testRunner.testCase.getTestStepByName("Unit DataSource")
dataSourceStep.finish( testRunner, context )


It results in the same error:

Thu May 29 14:59:02 EDT 2008:ERROR:java.lang.NullPointerException: Cannot invoke method finish() on null object


Are those the only two lines required in the groovy code test step?

Note that I'm not using an inner and outer (ie: two) datasource.. just the one datasource which I want to reset to the start for reuse.

I'm using soapUI 2.0.2 Pro TRIAL.
Jon
Contributor

Re: DataSource Inner/Outer Loop possibility

Update.

So I got it to work using:

def dataSourceStep = testRunner.testCase.getTestStepAt(0)
dataSourceStep.finish( testRunner, context )


Weird that it wouldn't work using the name, isn't it?  Note... the datasource name I actually had in the groovy code is longer (25 chars)... name has been changed to protect the guilty (but it was spelled correctly in the reference... I actually cut and pasted it to make sure!)
Super Contributor

Re: DataSource Inner/Outer Loop possibility

Hi!

hmm.. did the name contain any "special" characters?

/ole
eviware.com
Jon
Contributor

Re: DataSource Inner/Outer Loop possibility

Not a one.
Jon
Contributor

Re: DataSource Inner/Outer Loop possibility

Good Morning!

Do you have any other thoughts on this?  While it works using the teststep reference, it's annoying to have to change it if I change the order of test steps.
New Here?
Join us and watch the welcome video:
Join the exciting event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win