cancel
Showing results for 
Search instead for 
Did you mean: 

Set data source end row with property

SOLVED
Highlighted
Occasional Contributor

Set data source end row with property

I would like to set the "end row" of a "data source" using a property ("cycles" for instance) instead of a fixed value. This way I could create a loop of "n" cycles depending of the value I give to that property.

Is that possible to do with readyAPI 2.7.0?

Thanks and regards,

Joaquin.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

Re: Set data source end row with property

... and an example of setting the end row via Groovy:

 

// Example run from Groovy Script test step

def dataSourceTestStep = testRunner.getTestCase().getTestStepByName("DataSource")

dataSourceTestStep.setEndRow("5")

Note: The data source test step is the class WsdlDataSourceTestStep.

 

 

View solution in original post

11 REPLIES 11
Community Hero

Re: Set data source end row with property

Hey @jcabelloa 

 

I'm answering this cos noone else has yet.

 

It isn't possible with the out of the box Datasource functionality - however I'm sure I've seen something similar using groovy script a while back (but not on the forum - I was looking for something similar about 6 months ago and found a blog that mentioned doing this).  youd need to use Excel rather  than a flat file though.

 

I cant script myself - but the reason I'm answering is cos I'm wondering have you considered all possibilities for doing what you need or have you just latched onto the one option?  When trying to resolve a problem people tend to latch onto the first approach they think of and it isn't always the best/most efficient (I do this all the time).  Have you investigated altering your approach (so you dont need the cycles property) to use the out of the box functionality to get what you need instead?

 

Cheers,

 

rich

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
Contributor

Re: Set data source end row with property

Property expansion is supported for end row. You should be able to create a property to store the end row number and a groovy script to update the end row as needed.

 

 

Occasional Contributor

Re: Set data source end row with property

Hi @richie 

First of all thanks for your answer.

There are always other options for creating loops but "Data Source" is already out there and it works fine so I would really rather go for that solution than coding myself the loop.

I need to modify "End Row" with a property because some tests will neend 5 loop iterations and some other will need 30 iterations of the same loop (this is just an example).

I imagine I will have to code some groovy.

Regards,

Joaquin.

Occasional Contributor

Re: Set data source end row with property

Hi @jsheph01 

Thanks for answering.

Could you give some example of how to use that property expansion and how groovy could help on updating the end row? just a very simple example should be very helpfull. Or, maybe you know a place in the internet where I could have a look?

Thanks and regards,

Joaquin.

Super Contributor

Re: Set data source end row with property

You can find the property expansion documentation page here:

 

https://support.smartbear.com/readyapi/docs/testing/properties/expansion.html

Super Contributor

Re: Set data source end row with property

... and an example of setting the end row via Groovy:

 

// Example run from Groovy Script test step

def dataSourceTestStep = testRunner.getTestCase().getTestStepByName("DataSource")

dataSourceTestStep.setEndRow("5")

Note: The data source test step is the class WsdlDataSourceTestStep.

 

 

View solution in original post

Occasional Contributor

Re: Set data source end row with property

@Radford  Thanks a lot for your answer!

And, do you know how to set "DataSource - Number of Rows" property from groovy?

Thant would also be great to have.

Regards,

Joaquin.

Community Hero

Re: Set data source end row with property

@jcabelloa 

 

looking at the methods on the 'WsdlDataSourceTestStep' page @Radford mentioned, there are a lot less set methods than get methods.

 

There doesn't appear to be anything equivalent to "set number of rows" - but there is a setStartRow() method -  could you not use this in conjunction with the setEndRow() to set the "number of rows"?  I could be totally wrong - I'm new to all this "look at the API docs to work out the method you need thingy"

 

ta,

 

rich

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
Super Contributor

Re: Set data source end row with property

@jcabelloa, I'm not sure I understand what you are refering to when you say "DataSource - Number of Rows"? Do you mean the "Rows Per Iteration" option? If so I think you need:

 

// Example run from Groovy Script test step

def dataSourceTestStep = testRunner.getTestCase().getTestStepByName("DataSource")

dataSourceTestStep.setRecordsPerIteration(1)