cancel
Showing results for 
Search instead for 
Did you mean: 

How to load values from csv PRIOR to setting DataSource

SOLVED
Occasional Contributor

How to load values from csv PRIOR to setting DataSource

Hey Folks, 

 

Is there a way to access the csv file that is populating the datasouce prior to loading the datasource. I'm attempting to isolate only certain rows in the csv file but in order for this to be dynamic I need to be able to determine which rows the data exists so that I can populate the datasource with only those rows. 

 

Something like: 

 

def objGlobalProperties = com.eviware.soapui.SoapUI.globalProperties;
def regionToRun = objGlobalProperties.getPropertyValue("region");

def locale = context.expand( '${DataSource#locale}' )

if(locale == regionToRun)
{
def dataSourceTestStep = testRunner.getTestCase().getTestStepByName("DataSource")

def endRow = dataSourceTestStep.getCurrentRow()

dataSourceTestStep.setEndRow(endRow)

}

 

I'm not sure if I'm overcomplicating this so I'm open to suggestions. Ideally I would like it to completely ignore the data that isn't in the regions to be run. This is at the testcase level so if there is a way to run this from the project or suite level it would be even better. Each testcase has it's own csv file that it uses to populate the DataSource. 

 

Many thanks! 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

Re: How to load values from csv PRIOR to setting DataSource

Hi @caz88,

 

You can add a Groovy script right after your DataSource Test Step that will check if the region value from your source is equal or is not equal to something and based on this either continue the loop execution or jump to the end of the loop. Example:

comm.png

 

Natalie
Customer Care Team

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

5 REPLIES 5
Moderator

Re: How to load values from csv PRIOR to setting DataSource

Thanks for reaching out, @caz88!

 

Community, any ideas or suggestions?


Olga Terentieva
SmartBear Assistant Community Manager

Moderator

Re: How to load values from csv PRIOR to setting DataSource

Hi @caz88,

 

You can add a Groovy script right after your DataSource Test Step that will check if the region value from your source is equal or is not equal to something and based on this either continue the loop execution or jump to the end of the loop. Example:

comm.png

 

Natalie
Customer Care Team

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

Moderator

Re: How to load values from csv PRIOR to setting DataSource

Thank you, @NBorovykh!

@caz88, is this what you were looking for? We are looking forward to your results.


Olga Terentieva
SmartBear Assistant Community Manager

Occasional Contributor

Re: How to load values from csv PRIOR to setting DataSource

Hi @NBorovykh 

Thanks for the message - but have you ever noticed that this doesn't continue to run the tests and stops at the DataSource Loop? Is there a way to inject this method into the into each teststep while running the tests through the command line? 

 

We are running our ReadyAPI tests from Jenkins. At runtime we are only wanting to excute the tests in certain regions that we specify. These value would be passed to the testrunner from the jenkins job and then passed to to readyAPI. Any thoughts are being able to develop an approach this way? 

 

 

 

Community Manager

Re: How to load values from csv PRIOR to setting DataSource

Hi @caz88,

 

I'm not familiar with Groove very well. What if you add continue or return after "if"? Pseudocode:

if (region.....)
 ...
else
 return // or continue to move to the next test step
---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓