Forum Discussion

Ivan_Trampedach's avatar
Ivan_Trampedach
Contributor
14 years ago

DataSource and DataSink don't use same row no.

Hi
I have made this example, where I can't get datasink to update correct row. It look like DataSink and DataSource do not count in same way,

In DataSource I retreive data from an xls sheet,
I validate data in groovy, if validation pass I gotoStepByName "DataSource Loop"
In dataSink I update first column with a value.

It look like this in SoapUI
DataSource
Groovy
DataSink
DataSource Loop

Example
My groovy script jump to DataSource Loop if column 1 is not empty. If ='' DataSink should update with value 44

before run: After run Expected
Column 1 Column 2 Column 1 Column 2 Column 1 Column 2
1 AA 44 AA 1 AA
BB 44 BB 44 BB
2 CC 2 CC 2 CC
DD DD 44 DD

[/font:222vk990]

I can see in the log that my groovy script is jumping correct.
Is it possible to allign DataSink and DataSource to use same row ??

1 Reply

  • Hi,

    The DataSink is getting out of sync with the DataSource since it is not being invoked once per iteration, while the DataSource is always being invoked. To keep it in sync it needs to be called as often as the DataSource is called. This means that you will need to call it even when there is no data to write. Unfortunately there is no way to do this without writing data, so you'll have to overwrite the existing value for each line. To get the desired result you could read the "old" value in the DataSource (I take it you're using the same xls file in both Source and Sink?) TestStep, then modify the Groovy Script so that it either writes 44, or writes the "old" value read in the DataSource step. Would that work?

    Regards,
    Dain
    SmartBear Software