Forum Discussion

jcabelloa's avatar
jcabelloa
Occasional Contributor
5 years ago
Solved

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.

  • Radford's avatar
    Radford
    5 years ago

    ... 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.

     

     

11 Replies

  • richie's avatar
    richie
    Community Hero

    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

    • jcabelloa's avatar
      jcabelloa
      Occasional Contributor

      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.

  • 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.

     

     

    • jcabelloa's avatar
      jcabelloa
      Occasional Contributor

      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.

      • Radford's avatar
        Radford
        Super Contributor

        ... 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.