Functional Web Services Testing Made Easy with SoapUI - Part 2
log.info("In the WeatherTestSuite Setup Script")
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd")
todayStr = sdf.format(new Date())
props = new java.util.Properties ()
file = new File("C:/web-services-test/testprops.txt")
if(!file.exists())
{
file.createNewFile()
fis = new FileInputStream (file )
props.setProperty ( "today" , todayStr)
props.setProperty ( "zipCode" , "20904")
fos = new java.io.FileOutputStream ( file )
props.store(fos, "Writing the zipcode and today's date")
}
3. Add a Properties step.
Right click on the WeatherTestCase and select Add Step -> Properties. This opens up a new editor, within this editor create two new properties called, startDate and zipCode.
4.Within the setup script for the test case, we will read back from the properties file and assign the values to the properties step we added above. To recap:
log.info("In the WeatherTestCase Setup Script")
props = new java.util.Properties()
fis = new FileInputStream ("C:/web-services-test/testprops.txt")
props.load (fis)
today = props.getProperty ( "today" )
zipCode = props.getProperty ( "zipCode" )
targetStep = testRunner.testCase.getTestStepByName( "Properties" )
// transfer all properties
targetStep.setPropertyValue( "startDate", today)
targetStep.setPropertyValue( "zipCode", zipCode)
log.info(today)
log.info(zipCode)
- Login or register to post comments
- 34229 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
jbaker replied on Wed, 2008/11/19 - 3:20am
Meera Subbarao replied on Wed, 2008/11/19 - 8:05am
esad48 replied on Fri, 2009/01/16 - 6:26am
hi,
one question, is it possible to pass the responce from one test case to another test case. What i'm trying to do is to get a session id and then use that session id to run a load test.
Thx.
Meera Subbarao replied on Fri, 2009/01/16 - 10:58am
in response to: esad48
shanbala replied on Fri, 2009/02/27 - 2:25am
Meera Subbarao replied on Tue, 2009/03/03 - 11:18am
in response to: shanbala
sureshreddy04 replied on Wed, 2009/03/18 - 10:24pm
After seeing into ur article I whould like to know how can i obtain session ID to logout automatically when I login and logout of the webapplicaiton.
mevric75 replied on Tue, 2009/06/16 - 6:47pm
jafar_bt replied on Thu, 2009/08/06 - 4:25am
Hi Meera,
How could I change the project properties, test suite properties or testcase properties values using Groovy script test step. I wasn't able to understand the syntax.
def sessionID = context.expand( '${#Project#SessionID}' )
def testSuiteProperty = context.expand( '${#TestSuite#TestSuiteProperty}' )
def test1 = context.expand('${#TestCase#test}' )
I understood the above lines collect the values of the given properties. Please help me to set the value for SessionID, TestSuiteProperty, test parameters. Thanks in advance.
jafar_bt replied on Fri, 2009/08/07 - 2:29am
in response to: jafar_bt
I have found the info. The format is as follows:
testRunner.testCase.testSuite.project.setPropertyValue("SessionID","2002")
testRunner.testCase.testSuite.setPropertyValue("TestSuiteProperty","testSuiteProperty")
testRunner.testCase.setPropertyValue("test","testcase property")
However, I have another issue. If the assertion is faliled I am unable to continue to execute the further steps of testcase. Please help me regarding this concern...
kkairan replied on Mon, 2009/09/14 - 4:16am
I am trying to get the Node Value but I get it as Null
IST 2009:INFO:null
This is the Script I am running groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) holder = groovyUtils.getXmlHolder("GetData - Request 1#Response") dwmlByDayOut = holder.getNodeValue( "//GetDataResponse" )
Below are the Request Iam sending and the response I get
${Properties#Addvalue}
This is my response
You entered: 500
sztgeza replied on Fri, 2009/10/09 - 3:13am
Hi all!
For the TestCase setup script to work, i think it needs to add the following lines before file.createNewFile(), Otherwise i experienced an IOException, which was thrown by file.createNewFile(), when the parent directory had not existed before.
...
if(!file.exists())
{
if (file.getParentFile() != null) {
file.getParentFile().mkdirs()
}
file.createNewFile()
...
Nice article, anyway!
sunrise1 replied on Mon, 2009/10/26 - 3:26am
nkunchupu replied on Wed, 2009/11/25 - 7:31am