Ask a Question

How to load values from csv PRIOR to setting DataSource

SOLVED
caz88
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! 

 

 

5 REPLIES 5
Olga_T
SmartBear Alumni (Retired)

Thanks for reaching out, @caz88!

 

Community, any ideas or suggestions?


Olga Terentieva
SmartBear Assistant Community Manager

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.↓↓↓↓↓
Olga_T
SmartBear Alumni (Retired)

Thank you, @NBorovykh!

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


Olga Terentieva
SmartBear Assistant Community Manager

caz88
Occasional Contributor

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? 

 

 

 

TanyaYatskovska
SmartBear Alumni (Retired)

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 Yatskovskaya
SmartBear Community and Education Manager



cancel
Showing results for 
Search instead for 
Did you mean: