0

all

I am using free version of SoapUI. What I have is a test suite with many test cases. In each test case there is a request where I need to specify a date. So I want to create a general script for all cases and just call the result of it in each request I need.

What I do: 1. I have test suite SaveOperation where in SetupScript window at the bottom I write script:

def sdf = new java.text.SimpleDateFormat("yyyy-MM-dd")
def windowClosed = sdf.format(new Date()-20) 
log.info(windowClosed)

2. In this test suite I have many test cases as I wrote. So when for example in test case named SaveValid I need to specify Date parameter I write the following right in the xml request (in date parameter):

${#SaveOperation#windowClosed}

But it doesn't work. Could anyone suggest what is wrong with this way?

thank you in advance

Alyona Kovalyova
  • 109
  • 2
  • 13

1 Answers1

0

You have the correct approach. log.info() will only write the information to a log.

change

log.info(windowClosed)

to

testSuite.setPropertyValue("windowClosed", windowClosed.toString())

and then refer to it as:

${#TestSuite#windowClosed}
SiKing
  • 10,003
  • 10
  • 39
  • 90
  • In this row: `testSuite.setPropertyValue("windowClosed", windowClosed.toString())` Instead of **"windowClosed"** you mean I need to specify the actual name of parameter in a request? – Alyona Kovalyova Apr 14 '16 at 07:33
  • No. The code I showed is literal. See `setPropertyValue(String, String)` https://www.soapui.org/apidocs/index.html?com/eviware/soapui/model/TestPropertyHolder.html#setPropertyValue%28java.lang.String,%20java.lang.String%29 – SiKing Apr 14 '16 at 16:08
  • Thank you for such a long delay even though it is quite late ;) – Alyona Kovalyova May 16 '16 at 09:18