php - Groovy script for test steps in SoapUI -


in soapui (pro version) have 12 test steps:

  1. get request
  2. groovy script witch total value response previous step
  3. properties
  4. properties transfer
  5. post request 1
  6. post request 2
  7. post request 3
  8. post request 4
  9. post request 5
  10. post request 6
  11. post request 7
  12. post request 8

all post requests have id parameters.

question:

how write groovy script or maybe decision way:

if total = 8 set id parameters of post 1 = 1,post 2 = 1,post 3 = 1,post 4 = 1,post 5 = 1,post 6 = 1,post 7 = 1,post 8 = 1 if total = 7 set id parameters of post 1 = 2,post 2 = 1,post 3 = 1,post 4 = 1,post 5 = 1,post 6 = 1,post 7 = 1 if total = 6 set id parameters of post 1 = 2,post 2 = 2,post 3 = 1,post 4 = 1,post 5 = 1,post 6 = 1 if total = 5 set id parameters of post 1 = 2,post 2 = 2,post 3 = 2,post 4 = 1,post 5 = 1 if total = 4 set id parameters of post 1 = 2,post 2 = 2,post 3 = 2,post 4 = 2 if total = 3 set id parameters of post 1 = 3,post 2 = 3,post 3 = 2 if total = 2 set id parameters of post 1 = 4,post 2 = 4 if total = 1 set id parameters of post 1 = 8 

you use following in groovy [step 2]

def totalpoststeps = 8 def totalfromresponse = 7 //map 1 got prev response def postidarray = new int[totalpoststeps] def index = 0 1.upto (totalpoststeps, {     postidarray[index]+=1;     index = index==totalfromresponse-1?0:index+1 }) //log.info postidarray.tostring() postidarray.eachwithindex{num, idx ->      def numstring = num!=0?num.tostring():""      //the next step create/update properties in testcase custom properties , u can map these directly post requests      //or can set these directly step3 , continue step 4      testrunner.testcase.setpropertyvalue("idforpost_"+(idx+1), numstring)    } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -