This SOAtest Tutorial explains how to create a sample project, .tst file, test suite, and REST Client in Parasoft SOAtest. It also presents you with a glossary of the most important terms and describes major components of the application. It will provide you with an example of how a .tst file/project is built for API automation.
List Of Tutorials In This SOAtest Series.
Tutorial #1: Parasoft SOAtest Tutorial (This Tutorial)
Tutorial #2: SOAP Vs REST Difference
Tutorial #3: Assertion In SOAtest With An XML Code Example
Table of Contents:
What Is Parasoft SOAtest?
Parasoft SOAtest is a fully integrated API and web service testing solution that automates end-to-end functional API testing by streamlining automated testing with advanced codeless test creation for applications with multiple interfaces—REST and SOAP APIs, microservices, databases, and more.
Creating a Project in SOAtest
Multiple .tst files can be grouped into a single project.
First, we will create a new project based on existing test suites.
- Choose File > New > Project then select Project from Existing SOAtest Test Suites in the wizard that opens.
- Click Next.
- Enter Examples in the Project Name field.
- Specify the location of the project’s test suites by clicking Browse, then navigating to <SOATEST_INSTALLATION_DIRECTORY>/examples/tests.
- Click Finish.
The Examples project will be added to the Test Case Explorer. It will contain multiple test (.tst) files.
You can also create new projects by selecting different commands from the new project wizard. To see all available New Project options, choose File > New > Other and look under the SOAtest folder.
Creating New Test (.tst) Files
We recommend that you create a separate test (.tst) file for each distinct testing requirement. Right-click the project node and select Add New > Test (.tst) File from the shortcut menu.
- Choose File > New > Test (.tst) File.
- Enter Example in the File Name field,
- Click Next and then Finish
Later in this Tutorial, you will learn how to create an actual test inside your .tst file.
Major Components of a SOAtest Project
Below you will find a list of major hierarchical components of a SOAtest project.
#1) Project (Example)
A project is an entity created by the Eclipse IDE. It can contain any number of SOAtest-specific .tst files and any other resources that make sense for your environment.
#2) tst File (Example.tst)
It is the executable file that contains all the test suites, tests, environment variables, methods, data sources, traffic objects, etc. This file is the nucleus of your project. To keep file size down and to improve maintainability, we recommend using one .tst file for each distinct testing requirement.
#3) Test Suite (Scenario: Test Suite)
Test Suite is the folder inside your .tst file that contains the executable tests, data sources, environment variables, and so on. On the Test Suite level, you can set up execution mode (sequential or concurrent execution), test relationship (running each test individually or as a group), and test flow logic or declare any test variables which will be used for parameterization of your tests. Moreover, in this section, you can associate test cases with requirements managed by your ALM/RMS.
#4) Environment
Within this node you can configure multiple environments for different teams in your organization. SOAtest can help you seamlessly switch between those, without requiring any changes to the actual test.
Declaring Environment Variables
To declare Environment Variables in the Test Suite:
- Right-click Environments inside your Test Suite: Test Suite in theExample.tst file created in Creating New Test (.tst) Files section of this Tutorial.
- Click New Environment.
- Enter MyEnvVars in Name field.
- In the Environment Variables section enter ENDPOINT as a name and http://www.example.com as a value.
You have declared your first environment variable.
#5) Data Source
Tests can be parametrized with data stored in a data source. You can add data sources at either Test Suite, Project or Global level. The higher the level of the data source, the more widely it can be shared. For instance, if you want to add a data source that is applicable only to a specific Test Suite, add it at the suite level. If you want to share it across suites in a project, add it at the project level. If you want to share it across multiple projects, add it at the global level.
In case you want to capture runtime data for reuse in subsequent tools, you can use the Writable Data Source. It will provide you with several options like writing the output after each iteration or after complete execution. You can append (add to the previous execution) or overwrite/replace the data after each run.
Adding a New Data Source to the Test Suite
To create a new Data Source in the Test Suite:
- Right-click Test Suite: Test Suite inside the Example.tst file created in Creating New Test (.tst) Files section of this Tutorial.
- Click Add New > Data Source.
- Review the list of available types in the New Project Data Source box and select Table.
Your first Data Source is created.
#6) Test (Test 1: REST Client)
Within the Test Suite you create your actual tests. You can choose from various test clients, including (but not limited to) REST, GraphQL, SOAP, or CSV. A general-purpose Messaging Client is also available, with which you can add support for custom transports using the Extensibility Framework.
Adding a New Client to the Test Suite
To create a new client in the Test Suite:
- Right-click Test Suite: Test Suite inside the Example.tst file created in Creating New Test (.tst) Files section of this Tutorial.
- Click Add New > Test.
- Review the list of available clients under the New Tool tab and select REST Client.
Your first REST client is created.
#7) Traffic Viewer
Each time you run a client tool, SOAtest will automatically record the traffic to and from the designated endpoint. The Traffic Viewer tool helps you to manage and visualize the requests and responses associated with each tool. The Traffic Viewer can record multiple instances of traffic that correspond to each tool run.
#8) Other Components
SOAtest comes equipped with numerous different views that help you debug potential test execution issues (Quality Tasks, Event Monitor, Event Log), manage communication with message broker and retrieve the messages (Queue Browser), or manage your web scenarios for load testing (Load Test Explorer). For more information, please refer to the vendor’s website.
Creating and Configuring a Sample REST Client
- Create the ParaBank project:
- Go to File > New > Project.
- Choose SOAtest> ParaBank Example Project and click Next.
- Enter a name for the project, then click Finish.
ParaBank Example project will be created and deployed on port 8002 of your machine.
- Expand Example project created in Creating a SOAtest Project section of this Tutorial.
- Double-click SOAtestTutorial.tst to open the .tst file and review the contents,
- Expand Test Suite: REST Example and double-click Test 1: Loan Request (JSON Response).
- Note that Service Definition is set to None by default. Most RESTful services are purely GET-based services that are composed of a URL and a query; they usually respond with either an XML or JSON response payload.
- Provide the request to the RESTful service by changing the port in the URL inside URL field to http://localhost:8002/parabank/services/bank/requestLoan?customerId=1&fromAccountId=12345&amount=100&downPayment=1 , then choosing POST from the Method dropdown.
- Notice that SOAtest has automatically populated the table with path template and query parameters. If you wanted to add additional parameters, you could do so here.
- Click the HTTP Options tab, choose HTTPHeaders and note a header with name Accept and value application/json. If this header is omitted, the service response will be in XML. Once added, the service response will be in JSON.
- Save the REST Client editor.
Run the test and review the traffic in the Traffic Viewer. Note that you can switch from Literal to Tree view if you want to see a graphical representation of the JSON message.
Literal view:
Tree view:
Summary
In this tutorial, we saw how to create a project, .tst file, test suite, environment variable, data source, and REST Client in Parasoft SOAtest. This, in turn, will help you in building your own API test suite that you can execute on your own from scratch.
The second part of this Tutorial will focus on assertions and their types, JSON and XML databanks, working with API and Web UI Tests. After exploring these topics, you will be able to design your own test suite and automate your API tests.