Even if you don’t know what an API is, you most definitely have used it in some form or the other. Looking up the weather? You’re using an API. Checking what’s up with your friends on your Facebook app? That's an API call.
Technically, APIs (Application Programming Interface) are essentially a set of rules that specifies how two applications or systems communicate with each other. It allows data exchange between them. APIs usually form the middle layer between UI and the database. A very common example would be a third-party login for any application using your Google account. That application talks directly to the Google mail server to verify your account and get enough information to let you access their portal.
Now APIs come in different types of architectures depending on the protocols, access and functions. While REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) are the most commonly used APIs, GraphQL and RPC (Remote Procedural Call) protocols like XML-RPC, and JSON-RPC are a few others to name. In this article, we will be talking about testing SOAP and REST APIs using an open source testing tool called SoapUI.
What is API Testing
The API testing process involves testing the software interface directly. Testing APIs falls under integration testing to ensure functionality meets requirements. API testing is performed in the absence of a GUI interface with the help of tools such as SoapUI. The API test is conducted by requesting data from one or more API endpoints and comparing the results received with those expected.
Why API Testing
Now that we know something about APIs and API testing, let’s look into the benefits of API testing:
- API tests are a simple and effective way of covering all the functional tests of an application
- API tests can be performed even without a GUI
- API tests are the fastest method of performing functional tests. For example if 100 API tests take ~ 45 mins to complete, with GUI it would take around 3 - 4 hours to complete
- API tests are performed as part of integration testing between one or more applications.
What is SoapUI
SoapUI is an open source web-service testing application used to test SOAP, REST, and GraphQL APIs. SOAP uses only XML as a communication protocol whereas REST widely uses HTTP as its communication protocol. SoapUI was first released in 2006 by the Smart Bear developers.
Why Use It
Along with being very easy to work with and user friendly, you can use SoapUI as an API testing application to perform:
- Easy functional tests
- Security and vulnerability tests
- Load testing with LoadUI
- Mock API testing
- Data-driven tests and assertions
Some of the most powerful features include drag and drop test creation, complex scenario testing, data-driven testing, multi-environment support, and more.
How to create a basic SoapUI Test
Building a SoapUI test is very easy as I’ve already mentioned. As easy as 1 2 3 4 :) Take a look!
Step 1: Click on Create a new SOAP project
Step 2: Add the required project name and WSDL file(XML request template) - WSDL stands for Web Service Description Language. Click on the OK button.
Step 3: Click on the required test, update the parameters accordingly and click on the submit
request button for SoapUI to initiate a data request and display its expected outcome.
Step 4: Now compare the response with the expected response and we’re done!
I hope this article provides you with the required insight on API testing and using SoapUI to test SOAP and REST APIs. If you liked reading this article and would love to receive more such insightful blogs, do consider signing up for our newsletter.