1

I'm trying to transfer parameter from RawRequest using SoapUI but when reading it, value changes.

The parameter is request ID (which is unique for every test), it is requested by every test case from Custom Properties, where it is stored as follows:

${=((System.currentTimeMillis().toString()).subSequence(4, (System.currentTimeMillis().toString()).length())).replaceFirst("0", "")}

Above generates number like this for example:17879164.

The problem starts, when I'm trying to transfer it using either in build in feature or Groovy script. Both read parameter incorrectly:

Following is how the parameter presents in RawRequest window:

enter image description here

This is how it is read in Transfer window in SoapUI: enter image description here

And finally, how it is read by Groovy script: enter image description here

Can any one explain, why this value despite being shown in SoapUI RawRequest window as 17879164 is then read as 17879178 using two different methods?

I think the clue might be, that when I'm using "flat number" as reqId and not the generated one, both methods work fine and return correct number. But in this case when it is RawRequest, I understand that it is set once and for all, so what is show in the window and what is being read, should be the same.

QB1979
  • 123
  • 1
  • 8
  • Not sure about property transfer. But [here](https://github.com/nmrao/soapUIGroovyScripts/blob/b1f3a2eea91b1f82bd5f4c8ff9d4198afd7d3245/groovy/AssertJsonArrayElement.groovy) is groovy example to retrieve values. Please see if this helps. – Rao Jun 17 '16 at 18:38
  • Thanks Rao, this won't work in my case but looks useful for the future. Cheers – QB1979 Jun 18 '16 at 19:30

1 Answers1

1

What you are seeing is a "feature" in SoapUI. Your transfer step will transfer the code, which will then get evaluated again, resulting in a different value.

What you need to do is:

  1. Create a test case property.
  2. Set the property from test case setup script to a value. So in your case, something like testCase.setPropertyValue("your_property", ((System.currentTimeMillis().toString()).subSequence(4, (System.currentTimeMillis().toString()).length())).replaceFirst("0", ""))
  3. Anywhere in your test refer to the test case property ${#TestCase#your_property}... which is a fixed value at this point, so will be always the same.
SiKing
  • 10,003
  • 10
  • 39
  • 90
  • Thanks SiKing, I'll check this out Monday morning and let you know if it works! Cheers – QB1979 Jun 18 '16 at 19:32
  • Thanks a million @SiKing, this was a huge help. I still don't understand why SoapUI is invoking properties in such way. Makes no sense for me at all. Anyway, +1 to knowledge. If you don't mind, please vote up my question. It looks like I was down voted despite placing legitimate query, I'm just starting here, so every up vote counts. Big thanks! – QB1979 Jun 27 '16 at 11:51