Skip to Content

How do you create a REST project in SoapUI?

Representational state transfer (REST) is an architectural style for building web services. RESTful web services use HTTP requests to access and use data. SOAPUI is an open source cross-platform testing application for testing REST APIs. To test a REST API in SOAPUI, you need to create a REST project and make HTTP requests to the API endpoints.

Requirements for Creating a REST Project

To create a REST project in SOAPUI, you will need:

  • SOAPUI application installed
  • The base URL of the REST API you want to test
  • An understanding of the REST API endpoints and resources
  • Authentication details if the API requires authentication

Steps to Create a REST Project

Follow these steps to create a REST project in SOAPUI:

  1. Launch the SOAPUI application.
  2. Click on the “SOAPUI Projects” menu and select New REST Project.
  3. In the New REST Project dialog box, give your project a name.
  4. Enter the initial endpoint URL for the API in the Initial WSDL/WADL field. This is usually the base URL of the API.
  5. Expand the Settings section and configure any project level settings like SSL certificates.
  6. Click OK to create the project.

This will create a new REST project in SOAPUI with the given name and base URL. You can now start adding REST resources and test cases to interact with the API.

Adding Resources

Once the REST project is created, you need to add resources to interact with the API. Resources represent the endpoints and methods of the REST API. Follow these steps to add a resource:

  1. In the REST Project overview, right click on the project name and select Add Resource.
  2. Specify a name for the resource.
  3. Enter the relative path of the endpoint in the Path field. For example, /users.
  4. Select the HTTP method to use such as GET, POST, PUT, DELETE etc.
  5. Click OK to add the resource.

Repeat these steps to add all the required resources for interacting with the API. You can add multiple resources for each endpoint by using different HTTP methods.

Adding Test Steps

Once resources are added, you need to add test steps to make API calls and validate responses:

  1. Select a resource and click on the green plus icon to add a test step.
  2. Select the type of test step e.g. Properties, Property Transfer, Delay etc.
  3. Configure the parameters for the test step.
  4. Add assertions to validate the response.
  5. Add more test steps as required and order them using the arrow buttons.

This way you can build complete test cases with multiple steps to test scenarios of the API.

Example REST Project

Let’s look at an example of testing a simple REST API for a social network. The API has endpoints for user profiles and posts.

Project Settings

Create a new project named SocialNetAPI with the base URL set to https://api.socialnet.com.

Resources

  • /users – GET request to retrieve list of users
  • /users/{userid} – GET request to retrieve a user profile
  • /posts – GET request to retrieve posts
  • /posts – POST request to create a new post

Test Cases

Some example test cases for this API could be:

  1. Get list of users and validate response code and body.
  2. Get a specific user profile and validate user id, name etc.
  3. Create a new post and validate response code and body.
  4. Get list of posts and validate pagination and post contents.

These test cases can then be organized into test suites for easier execution.

Advanced Testing Concepts

SOAPUI provides many advanced testing capabilities for REST APIs including:

  • Authorization – add OAuth, API Key or Basic Authentication
  • Property Transfers – transfer values between test steps
  • Data-driven Testing – parameterize and data drive test cases
  • Assertions – validate response codes, headers, body contents
  • Custom Scripts – write Groovy or JavaScript scripts
  • Mock Services – simulate APIs for testing

Executing and Analyzing Tests

To run the test cases in a REST project:

  1. Select the test case or test suite to run.
  2. Click on the green play button.
  3. View the request and response logs.
  4. Analyze the test results and reports.

You can integrate SOAPUI with tools like Jenkins to automate API test execution and reporting as part of your CI/CD pipelines.

Conclusion

SOAPUI provides a comprehensive set of features for testing REST APIs. By following the steps to create a REST project, add resources, test cases and integrate with automation tools, you can fully test your REST APIs using SOAPUI.