0

I have a header called RequestID that has a value of a UUID I generated in the groovy script below:

import static java.util.UUID.randomUUID
import com.eviware.soapui.support.types.StringToStringMap  

def uuid = randomUUID() as String
def headers = new StringToStringMap()

headers.put("RequestID", uuid)
testRunner.testCase.getTestStepByName("Get Username").testRequest.setRequestHeaders(headers)

I also have a REST request named "Get Username" that is called multiple times via a datasource loop. My groovy script seems to only be generating one UUID for the entirety of the loop and not a new UUID for each hit. Am I missing something in my script or is the order of the steps wrong? I'm also using a grid in my datasource step called SSN to feed data into the request.

Here is the order of my steps in SOAPUI:

  • SSN
  • Groovy Script
  • Get Username,
  • DataSource Loop (Datasource step: SSN, Target step: Get Username)

Essentially every time a new request is sent, there should be a new requestid. If that makes sense.

Jeffrey Lee
  • 51
  • 10
  • Your script seemed ok. does not seem to be an issue. It will keep generating new uuid in each loop. Isn't it? – Rao Mar 28 '17 at 05:24
  • @Rao, i'm not entirely sure. Is there a way to slow down the execution of a testcase in soapui to check? Because according to some logging it looks like it's using the same uuid for the duration of the datasource loop – Jeffrey Lee Mar 28 '17 at 17:27
  • If you are using readyapi1.9, there is debugging feature. – Rao Mar 29 '17 at 01:11

1 Answers1

1

When the test reaches the DataSource Loop it gets new data from the DataSource and executes the target test step (in your case - Get Username). So it executes the Groovy script only once.

Change the Target test step in the DataSource Loop to the Groovy Script test step.

Fill Freeman
  • 189
  • 9