cancel
Showing results for 
Search instead for 
Did you mean: 

Looping a static amount of times only for a few requests

New Contributor

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 5
Highlighted
Community Hero

Re: Looping a static amount of times only for a few requests

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

 

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 title of the post to something more descriptive? This will help people when searching for problems.
Community Leader

Re: Looping a static amount of times only for a few requests

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.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
New Contributor

Re: Looping a static amount of times only for a few requests

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.

New Contributor

Re: Looping a static amount of times only for a few requests

Hey,

 

Can anyone please help me with the Groovy script writing?

I've described my needs in the last reply.

 

Thank you!

Community Manager

Re: Looping a static amount of times only for a few requests

Hi @Isaac,

 

If you are looking for a groovy script to read an Excel file, please refer to the following topics:

https://community.smartbear.com/t5/SoapUI-Pro/Get-xls-data-in-loop-in-groovy-script/td-p/27864

https://community.smartbear.com/t5/SoapUI-Open-Source/HOW-TO-READ-EXCEL-FILE-IN-GROOVY/td-p/178242

https://stackoverflow.com/questions/22031375/reading-excel-and-writing-to-xml-in-groovy-for-soapui

 

Also, I recommend that you read the following doc articles:

https://support.smartbear.com/readyapi/docs/testing/scripts/samples/index.html

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2