title: SoapUI Load test groovy sequentially reading txt file
body: <p>I am using free version of soapui. In my load test, I want to read request field value from a text file. The file looks like following</p>
  
  <pre><code>0401108937
  0401109140
  0401109505
  0401110330
  0401111204
  0401111468
  0401111589
  0401111729
  0401111768
  </code></pre>
  
  <p>In load test, for each request I want to read this file sequentially. I am using the code mentioned in <a href="https://stackoverflow.com/questions/27424797/unique-property-per-soapui-request-using-groovy">Unique property per SoapUI request using groovy</a> to read the file. How can I use the values from the file in a sequential manner?</p>
  
  <p>I have following test setup script to read the file</p>
  
  <pre><code>def projectDir = context.expand('${projectDir}') + File.separator
  def dataFile = "usernames.txt"
  
      try 
      {
          File file = new File(projectDir + dataFile)
          context.data = file.readLines()
          context.dataCount = context.data.size
          log.info "     data count" + context.dataCount
          context.index = 0; //index to read data array in sequence
      } 
      catch (Exception e) 
      {
          testRunner.fail("Failed to load " + dataFile + " from project directory.")
          return
      }
  </code></pre>
  
  <p>In my test, I have following script as test step. I want to read the current index record from array and then increment the index value</p>
  
  <pre><code>def randUserAccount = context.data.get(context.index);
  context.setProperty("randUserAccount", randUserAccount)
  context.index = ((int)context.index) + 1;
  </code></pre>
  
  <p>But with this script, I always get 2nd record of the array. The index value is not incrementing.</p>