SoapUI is an open source functional testing tool widely used for API testing. The most attractive feature of this tool is that it supports all types of protocols and technologies. Besides it provides complete test coverage too.
What is SOAP ?
SOAP is a simple protocol and it is XML based. It permits applications to exchange information over HTTP and uses WSDL or Web Services Description Language for communication. WSDL also facilitates the interaction of other applications with Web Service.
What is SOAPUI ?
SOAPUI is a web service testing tool. It is compatible with multiple platforms. SOAPUI is a free and an open source tool. SOAPUI- pro is an advanced version of this tool and it has additional functionalities which are essential for companies dealing with critical web services. As web services play an important role in the internet application, SOAPUI has a great significance in today’s world.
SoapUI with Selenium
As you are already aware, Selenium is the most widely used tool for automating tests. It can automate browsers across multiple platforms and Selenium webdriver can have direct access to the browser. Actually, selenium webdriver uses the native support of the browser for automation. SOAPUI can integrate with Selenium for enhancing the functionalities. Using Groovy, it can be done easily as SOAPUI supports Groovy extensively.
Groovy is a scripting language and it is objected oriented scripting language with all the Java libraries. Hence, all the keywords and functions related to the Java scripting language can be used with Groovy too. Java Virtual Machine will be integrated with it.
You should perform the following things for using SOAPUI with Selenium
- Downloading Groovy SDK
- Installing Java SDK
- Installing Selenium
- Installing SOAPUI pro
Call the SOAPUI test case runner in Selenium
Given below is an example and here the purpose is to set the properties of cities with corresponding zip code. When the following code is executed, it will get the values of cities and zip codes. It will also display the failure count that does not match with the cities or zip codes. This can be run on Selenium and you have to follow strictly the instructions given below.
- Startup SOAPUI
- Start a new test case
- Add a new Groovy step
- Copy and paste the sample code into the Groovy step
- Click on “Play” button
- First the Firefox will starts up and then navigate to Google. After that you will see SOAPUI log entries.
- Code runs using JUnit.
@when(“<I use the weather service to get the weather information”)
public void i_use_the_weather_service_to_get_the_information() {
Set<Entry<String, string>> set = zipAndCities.entrySet();
while (iterator,hasNext)) {
Entry<String, String> entry = iterator.next();
String zipCode = entry.getkey();
String city = entry.getValue();
String[] prop = {“usePropertyFileFlag=true”,”zipCode=” +zipCode, “city=” +city};
public void i_use_the_weather_service_to_get_the_information() {
Set<Entry<String, string>> set = zipAndCities.entrySet();
while (iterator,hasNext)) {
Entry<String, String> entry = iterator.next();
String zipCode = entry.getkey();
String city = entry.getValue();
String[] prop = {“usePropertyFileFlag=true”,”zipCode=” +zipCode, “city=” +city};
try{
SoapUITestCaseRunner soapUITestCaseRunner = new SoapUITestCaseRunner();
soapUITestCaseRunner.setProjectFile(“src/test/resources/WeatherSoapTest-soapui-project.xml”);
soapUITestCaseRunner.setProjectProperties(prop);
soapUITestCaseRunner.setTestSuite(“TestSuite1”);
soapUITestCaseRunner.setTestCase(“TestCase1”);
soapUITestCaseRunner.run();
SoapUITestCaseRunner soapUITestCaseRunner = new SoapUITestCaseRunner();
soapUITestCaseRunner.setProjectFile(“src/test/resources/WeatherSoapTest-soapui-project.xml”);
soapUITestCaseRunner.setProjectProperties(prop);
soapUITestCaseRunner.setTestSuite(“TestSuite1”);
soapUITestCaseRunner.setTestCase(“TestCase1”);
soapUITestCaseRunner.run();
} catch (Exception e) {
System.err.println(“checking” + zipCode + ” failed!”);
failureCount++;
zipCodes.append(zipCode + ” [” + city +”] “);
e.printStackTrace();
}finally{
totalCount++;
}
}
}
}
System.err.println(“checking” + zipCode + ” failed!”);
failureCount++;
zipCodes.append(zipCode + ” [” + city +”] “);
e.printStackTrace();
}finally{
totalCount++;
}
}
}
}
The console view enables us to have a glance at all the test cases executed. You will find a list of zip codes, cities fetched and passed into the SoapUI Test Case 1.
No comments:
Post a Comment