Rajesh Varma
Rajesh Varma

Reputation: 149

How to trigger REST request in SOAPUI with Groovy script test step

With the below script I'm able to send the data/payload to my POST request. However, notable to run the post request from the script. Need post request in loop.

def POSTForgivness = testRunner
   .testCase
   .getTestStepByName("postforgivness")
   .getT‌​estRequest() 
POSTForgivness.setRequestContent(ForgivnessPayload)

Other info from comments:

Upvotes: 1

Views: 5662

Answers (2)

Rao
Rao

Reputation: 21389

Here you go: sudo code

  1. get the test step by name
  2. set the new request to next step
  3. run the step
  4. need to disable the rest step as every thing is controlled by step1 (which is groovy script step)
//Get the next step
def nextStep = context.testCase.getTestStepByName("postforgivness")
//Set the new request
nextStep.httpRequest.requestContent = ForgivnessPayload
//run next step
nextStep.run(testRunner, context)

Just loop thru the above code until you finish the data

Upvotes: 1

Chris Adams
Chris Adams

Reputation: 1454

Re Need post request in loop.

This sounds like a data-driven test as opposed to a load test.

Place your post-forgiveness request between a 'Data Source' step and a 'Data Source Loop' step.

You can then 'loop' over your post-forgiveness step as many times as there are rows set up in your data source step. For each row you have set up, you can define the payload to 'squirt' into your request.

There is an excellent article on the SoapUI website https://www.soapui.org/data-driven-tests/functional-tests.html.

Upvotes: 0

Related Questions