Functional Web Services Testing Made Easy with SoapUI - Part 2
So much for preamble, let’s get to work. If you followed along with part 1 of this series, you should already have an NOAA-Weather-Service project. We’ll continue with the same web service here. In our earlier test case; we used today’s date and the latitude and longitude for Silver Spring. In the NDFDgenByDay Request, the startDate must be a String in the format “yyyy-MM-dd”. The NOAA web service has a function that returns us the latitude and longitude when provided with a ZIP code. This time we will read the data we require for this functional test from a properties file.
Let’s remind ourselves of the steps to creating the Test in SoapUI:
1.Create a New Test Suite and a Test case.
2.Within the Test Suite setup script, if the properties file does not exists, write to a new properties file today’s date and the default ZIP code.
3.Create a Properties object and assign the values read from the properties file to it.
4.Within the test case setup script, read from the properties file.
5.Use the zipCode property from the above step in the LatLonListZipCode request, which will return the latitude and longitude to us.
6.Use Groovy to assert that we retrieved the correct ZIP code and transfer the latitude and longitude down the line.
7.The NDFDgenByDayLatLonList request now uses the date from the property step 1, and the latitude and longitude from step 6.
8.Lastly, use Groovy step to parsing the XML, validate the response, and assert the results.
1. Create a New Test Suite and Test Case. Follow these steps:
a. Right click on the project, and select the New TestSuite menu item. Specify the name WeatherTestSuite.
b. Right click on the Test Suite you created above and select the New TestCase menu item. Specify the name WeatherTestCase.
- Login or register to post comments
- 34305 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