Forum Discussion

Sean_Paterson's avatar
Sean_Paterson
Occasional Contributor
17 years ago

How to transfer a dynamic property to subsequent test steps?

Hi, I am using the soapUI 2.5 beta1.  I have a test case that starts with a Properties API step.  I use it to set dynamic values for sessionid and username properties, for example username = ${="API_PerfTest" + (int)(Math.random()*10)}.  A subsequent test request step uses this username property by using ${Properties API#username} between the tags.  So far so good.  I then wish to make use of the actual (RAW) username value that was used in this test request step so that it can be read into another test request step.  I have tried using a Property Transfer step but it does not seem to be able to capture the RAW value that was previously used.  Consequently the following test request steps fail.  How do you advise achieving this?  BTW - I am a first time user of soapUI and I really like the tool, although I am not familiar with Groovy and never done any Java coding.

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    I suggest you set the value of the username property using a standalone groovy script step that you run before the properties-step; in this way you can use the value of the property in all situations (since it created only once..)

    Alternatively check out the DataGen teststep in soapUI Pro (http://www.soapui.org/userguide/functio ... nstep.html) that has a script-property type which will handle this since it can be set to update its value only when the containing step is executed.

    regards!

    /Ole
    eviware.com
  • Sean_Paterson's avatar
    Sean_Paterson
    Occasional Contributor
    Hi Ole,
    Many thanks for your quick reply.  I tried your suggestion and it worked.  I inserted a Groovy Script as the first test step, called "Set the username", with just the one line of script to initialise and define the 'dynamic' username value to be persisted down through all the test steps as follows :
    def myusername = "MySoapUITester" + (int)(Math.random()*10)
    I then modified the property transfer test step before the test requets step to move myusername, setting the Source = "Set the username" and Property = "Result" and setting the Target as normal to my test request step's request property.

    Thanks again.
    Sean