Forum Discussion

Isaac's avatar
Isaac
New Contributor
5 years ago

Looping a static amount of times only for a few requests

Hey,

 

I am not a developer, therefore not really familiar with the groovy script, but I'll try to describe my problem:

 

I am using a DataSource to grab info for requests. 

Those requests' responses will then go into DataSink output.

My requirement is that request X will be performed 5 times for every request Y, and the output should be as follows:

 

ID-X        ID-Y

123          000

234          000

345          000

456          000

678          000

12             00

23             00

34             00

45             00

56             00

 

I tried nested loops and got tangled, plus I cannot define a certain amount of times for each DataLoop (while statement).

 

I appreciate any help.

 

Thanks,

Isaac.

 

5 Replies

  • Hi Isaac ,

     

    You can achieve this via writing your custom groovy code that will execute particular Test Cases.

    For more help you case share your code where you are stucking. I will be happy to help.

     

  • richie's avatar
    richie
    Community Hero

    Hi Isaac 

     

    I was wondering if you could provide a bit more detailed information about your use case?

     

    what sort of datasource are you using?

    what data is contained within your datasource? (just attribute values or whole payloads?)

    Is it REST?

    Is it JSON/XML?

    What's the purpose of the datasink - are you just writing out the responses to the datasink and that's it?

    you say Request X will be performed 5 times for every Request Y - how do you envision this working - Does RequestX have to execute before RequestY or the other way around or something different?

    I couldn't really envision what the 2 columns of output you provided was supposed to represent

     

    The more detailed info you provide the more likely someone's gonna be able to help you out,

     

    nice one,

     

    richie

     

  • Isaac's avatar
    Isaac
    New Contributor

    Hey, I'll try to give as many details as I can.

    My DataSource is an Excel file. Its purpose is to basically have a payload adjustment for each test case.

    Those payloads are then injected into requests.

    So the flow structure is:

    DataSource

    Request X (REST)

    Request Y (REST)

    DataSink

    DataLoop

     

    The DataSink writes requests X&Y IDs responses into the same Excel file.

    I need that for each request X response ID there will be a Y response ID (as I described in the table of the original message).

     

    All is fine when I require the loop to go over the entire flow again & again until the DataSource ends.

     

    What I'm missing is setting the loop to run a defined amount of times (while loop), then I could use it 5 times for request X as a nested loop, and a 'big' loop for the entire flow.

     

    Thanks a lot!

    Isaac.