Ask a Question

Reseting datasource to first row

New Contributor

Reseting datasource to first row



I have a functional test in which I am using same datasource step in two different loops. First loop is to create a data, second loop to validate. However I am unable to loop the datasource second time - it "loops" only the last row.


I have tried to create a groovy script between these loops to validate whether "ds.getRestartOnRun()" and "ds.setRestartShared()" are true and yes, they both are true for that datasource step.


Why the datasource is not reseting by itself when those two params are set to true? Is there any way to trigger the reset from script or set the current row?



Community Hero

Hey @asnaeb,

Can you send a screenshot of your testcase please? Im struggling to visualise what youre doing, but without engaging my brain too much (ive had no sleep since Monday), im guessing your issue might be linked to trying to do too many things witha single datasource object....especially if youve got 2 datasource loop objects in your test.

If i can see your testcase object hierarchy that will probably help me.


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
Champion Level 2



If your loops are nested, e.g.


---- DatasourceStepOne

---- DatasourceLoopTwo


Then I cannot see how it would work.


In your description, you say Create, then Validate and I read this as two loops.  e.g.

// Let's create out data.

   SomeCallToCreateDate - REST Request


//Data created, wait a bit.

// Let's validate

    SomeValidateStep - REST Request



This would be perfectly valid.  There's no reason why the same file cannot be used in two different datasource steps.  But, as @richie suggested, some screenshots would help.


New Contributor



sorry for just a brief description, will try to explain more:


I have a two separate loops, one after another, no nesting. Something like ChrisAdams's second example, but with just one datasource.


This my test case (screenshot_61.jpg):

- Step1: GetList (REST request)

- Step2: DataSource (from JSON response of Step1 (GetList) - 73rows)

-- Step3: CreateData (REST request in loop. uses ${DataSource#data}. it gets executed 73 times.)

-- Step4: DataSourceLoop1 (Data Source Step: DataSource, Target Step: CreateData)

- Step5: GetAnotherList (REST request.)

-- Step6: ValidateItemInList (Assertion. uses ${DataSource#data} and validates against GetAnotherList.response. it gets executed only 1 time (for last row of DataSource)) 

-- Step7: DataSourceLoop2 (Data Source Step: DataSource, Target Step: ValidateItemInList)


So the problem is step 6/7. I would expected the loop for that datasource go again from row 1 to row 73, but it only executes the 73th row.


Transaction log: Screenshot_62.jpg .


P.S. I have set testcase to continue on errors.



You're only missing a second Datasource test step.


Insert a new Datasource step either before Step 5 for Step 6.  Call the step itself something different, like "Datasource - validate"  I suspect before Step 6 is the place.


Then update DataSourceLoop2 to point at the "Datasource - valdidate" datasource step.


Why did it not work?  The Datasource step keeps track of the current row whilst the testing is running.  When the test runs again, it resets, but it doesn't reset in the context of the same test running.  That's why the second loop is on the last row.

Thanks, that explains it. So the "RestartOnRun" param reffers to "run" of test case. Was hoping that it could somehow be solved with one data source. Having and maintaining two data sources that holds the same data, same columns, same props... seems like a copy&paste work 😞


But I would still like to ask whether there is a way to set current data source row from Groovy Script. In API docs I can see two public methods of WsdlDataSourceTestStep regarding rows - setEndRow and setStartRow, but that only limit datasource range. Is there some way to set current row? I am not sure whether I read the right/actual API docs (, because it links to lot of non-existing 404 pages.

New Contributor

Ok I was playing with that and it's possible by ds.SetStartRow() and then calling ds.restart(testRunner,context)  🙂 Like that it can work even with one data source.

Showing results for 
Search instead for 
Did you mean: