cancel
Showing results for 
Search instead for 
Did you mean: 

Re: help: property as function of another property

Highlighted
Occasional Contributor

Re: help: property as function of another property

Hi,

please help

I have this request:


 

 
     
        2
        24
     

 


I want the crsNum to be random between 1 and 4, I did that using property expansion: ${=(int)(Math.random()*10)}
Q: I want StudentAge to be function of crsNum, how to do it in soapUI Pro?
Ex: if crsNum=1, then StudentAge= 10 to 20
      if crsNum=2, then StudentAge= 20 to 30
      and so on

Another example If I have property t1=current time, How to set another defined property t2=t2-t1

thank you in advance ..
1 REPLY 1
Highlighted

Re: help: property as function of another property

Hello,

The easiest way to do this would be to have a separate Groovy TestStep before the actual request where you set these as Test Properties in for example the TestCase. For instance:


def crsNum = (int)(1 + Math.random()*4)
def studage = (int)(crsNum*10 + Math.random()*10)

testRunner.testCase.properties['crsNum'].setValue( (String)crsNum )
testRunner.testCase.properties['StudAge'].setValue( (String)studage )


And then in your request use the property expansions as follows:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ejb="http://EJBcourse.sun.com/">
  <soapenv:Header/>
  <soapenv:Body>
      <ejb:checkAgeFull>
        <crsNum>${#TestCase#crsNum}</crsNum>
        <StudAge>${#TestCase#StudAge}</StudAge>
      </ejb:checkAgeFull>
  </soapenv:Body>
</soapenv:Envelope>


You will need to first create the two Test Properties in the TestCase for this to work.

Regards,
Dain
eviware.com


Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors