Skip to content
VirtualLP Virtual Learning Platform

Practical 22: API Testing with SoapUI and Postman

20 min read Topic 31 of 31 1 hands-on lab

Aim

Use SoapUI and Postman to test the Students API (Application Programming Interface). Add, read, update and delete records. Check reply data and status codes. Run the SoapUI load test to measure response time, completed requests and errors.

Theory

API testing sends requests directly to a service. You check its replies without clicking through the website.

An endpoint is the address for an API operation. The request body carries data you send. The response body carries data the service sends back. Test the data and the status code.

testing a vending machine

Instead of judging a vending machine by its lights and buttons (the UI (User Interface)), you test what it actually gives: put in ₹20 and press B2 → do you get the right chips and the right change? Press a code that does not exist → do you get "invalid" (like 404)? API testing checks the answers of the service directly. A load test is like 20 or 100 people using the machine at the same time.

What to verify in an API response

Check Example
Status code 201 Created after POST, 404 for an unknown ID
Headers Content-Type: application/json, Location header
Payload / body $.name == "Priya Sharma", array length, data types
Schema Response conforms to a JSON (JavaScript Object Notation) Schema / OpenAPI contract
Response time < 500 ms (SLA (Service Level Agreement))
Error handling Invalid input → 400 with a clear message
Security Missing token → 401; other user’s data → 403

SoapUI vs Postman

SoapUI (SmartBear, open source) Postman
Desktop tool (Java) for SOAP (originally Simple Object Access Protocol) and REST (Representational State Transfer) Desktop/web tool mainly for REST / GraphQL
Project → Test Suite → Test Case → Test Steps Workspace → Collection → Folder → Request
Assertions through GUI (Graphical User Interface) (Valid HTTP (Hypertext Transfer Protocol) status, Contains, JSONPath Match, XPath, Schema compliance, SLA) Assertions in JavaScript (pm.test, pm.expect)
Property transfer between steps Variables (pm.environment.set)
Built-in load testing (LoadTest strategies) Performance runner (limited); Newman CLI (Command-Line Interface) for CI
Groovy scripting JavaScript scripting

The service under test – Students API

Base URL (Uniform Resource Locator): https://api.virtuallp.test/v1

Method Endpoint Description Success
GET /students List students 200
GET /students/{id} Get one 200 / 404
POST /students Create 201 + Location
PUT /students/{id} Replace 200
DELETE /students/{id} Delete 204

Sample student JSON:

{ "id": 101, "name": "Priya Sharma", "email": "priya@example.com", "course": "Cloud Computing", "cgpa": 8.7 }

Requirements

The .test addresses refer to the simulated practice app. Outside the simulator, use a running test app and its actual addresses and page elements.

  • SoapUI Open Source 5.7 and/or Postman desktop app.
  • The Students API (simulated in the virtual lab).

Procedure – Part A: Functional testing with SoapUI

  1. File → New REST Project → URI (Uniform Resource Identifier) https://api.virtuallp.test/v1/students → OK. SoapUI creates a Service → Resource → Method → Request.
  2. Open Request 1 (GET) → click ▶ Submit → view the JSON in the JSON tab of the response.
  3. Right-click the request → Add to TestCase → create Test Suite Students API Suite and Test Case CRUD flow.
  4. Add these test steps (REST requests) to the test case:
    1. GET all students
    2. POST create student – Media type application/json, body:
{ "name": "Rahul Verma", "email": "rahul@example.com", "course": "Cloud Computing", "cgpa": 8.1 }
  1. Property Transfer – move $.id from the POST response into test-case property studentId.
  2. GET student by id – resource /students/${#TestCase#studentId}
  3. PUT update student – change cgpa to 8.5
  4. DELETE student
  5. GET deleted student – expect 404.
  6. Add assertions to each step (click Assertions (+)):
Step Assertions
GET all Valid HTTP Status Codes 200; JSONPath Count $[*] ≥ 1; Response SLA 500 ms
POST Valid HTTP Status Codes 201; JSONPath Match $.name = Rahul Verma; Contains "id"
GET by id 200; JSONPath Match $.email = rahul@example.com
PUT 200; JSONPath Match $.cgpa = 8.5
DELETE Valid HTTP Status Codes 204
GET deleted Valid HTTP Status Codes 404; Contains Student not found
  1. Negative tests: POST with missing email → expect 400 and message email is required; GET /students/abc → 400.
  2. Run the Test Case (▶). Steps turn green (pass) or red (fail); the TestCase log shows each step’s time and status.

Groovy script assertion (optional)

import groovy.json.JsonSlurper
def json = new JsonSlurper().parseText(messageExchange.responseContent)
assert json.cgpa instanceof Number
assert json.cgpa >= 0 && json.cgpa <= 10
assert messageExchange.timeTaken < 500

Procedure – Part B: Load testing with SoapUI

  1. Right-click the test case → New LoadTest → name Students Load.
  2. Set up:
    • Threads: 20 (concurrent virtual users)
    • Strategy: Simple (fixed threads, test delay 1000 ms, random 0.5) – or Variance, Burst, Thread (ramps threads from start to end count).
    • Limit: 60 seconds.
  3. Add LoadTest Assertions: Max errors 5, Average < 500 ms, TPS ≥ 15.
  4. Run the load test and watch the statistics table and graph: min, max, avg, last, count, TPS (transactions per second), err, ratio.
  5. Repeat with a Thread strategy ramping from 10 to 100 threads to observe scalability.

Sample load test statistics (20 threads, 60 s)

Test step              min   max   avg   last  cnt   tps    bytes   bps     err  rat
GET all students        38   412    96    88   1104  18.4   2.3MB   39K       0   0
POST create student     52   601   141   120   1102  18.3   0.4MB    7K       0   0
GET student by id       31   355    84    77   1101  18.3   0.3MB    5K       0   0
PUT update student      49   590   133   126   1100  18.3   0.4MB    7K       0   0
DELETE student          35   402    90    81   1100  18.3   0.1MB    1K       0   0
GET deleted (404)       29   311    71    66   1100  18.3   0.1MB    1K       0   0
TestCase:              260  2201   615   558   1100  18.3   ...                0   0

At 100 threads the average for POST rose to ~860 ms and errors appeared (HTTP 503) – the service's scalability limit for writes.

How to read the table: min/max/avg = fastest, slowest and average time in ms; cnt = how many times the step ran; tps = transactions per second; err = errors. Here every step ran ~1100 times at ~18 TPS with 0 errors.

Virtual lab · Testing Tools · 45 min

Functional and load testing of a REST API with SoapUI and Postman

Build a SoapUI test case for the Students API with assertions and property transfer, run a load test, then recreate the checks in Postman with test scripts, an environment and the Collection Runner.

Open lab

Procedure – Part C: The same tests in Postman

  1. Create a Collection Students API and an Environment with baseUrl = https://api.virtuallp.test/v1.
  2. POST {{baseUrl}}/students with the JSON body; Tests tab:
pm.test("Status is 201 Created", () => pm.response.to.have.status(201));
pm.test("Location header present", () => pm.response.to.have.header("Location"));

const body = pm.response.json();
pm.test("Name saved correctly", () => pm.expect(body.name).to.eql("Rahul Verma"));
pm.test("Response under 500 ms", () => pm.expect(pm.response.responseTime).to.be.below(500));

pm.environment.set("studentId", body.id);            // chain to the next request
  1. GET {{baseUrl}}/students/{{studentId}} with tests for status 200 and a JSON schema:
const schema = {
  type: "object",
  required: ["id", "name", "email", "course", "cgpa"],
  properties: {
    id: { type: "integer" }, name: { type: "string" }, email: { type: "string" },
    course: { type: "string" }, cgpa: { type: "number", minimum: 0, maximum: 10 }
  }
};
pm.test("Matches schema", () => pm.response.to.have.jsonSchema(schema));
  1. Run the collection with the Collection Runner (iterations, delay, data CSV (Comma-Separated Values)), or from CI with Newman:
npm install -g newman
newman run Students.postman_collection.json -e dev.postman_environment.json -n 5 -r cli,htmlextra

Output / Observations

Example output for the settings in this lesson:

  • Functional suite: all 7 test steps passed, 21 assertions, including the negative 404 and 400 checks.
  • Chained requests worked through property transfer (SoapUI) / environment variables (Postman).
  • Load test: at 20 users the API sustained ~18 TPS with average step time under 150 ms and 0 errors; at 100 users write operations slowed and some returned 503 – indicating the need for scaling (more instances behind a load balancer, database tuning).

Conclusion

Check every CRUD (Create, Read, Update and Delete) request and its response. Confirm that a deleted record returns 404. Compare the load-test timings and errors. Run the matching Postman checks and read their results.

Viva questions

  1. What is API testing? Why is it preferred over UI testing for business logic? Testing endpoints directly by sending requests and checking responses; it is faster, more stable and can start before the UI exists.
  2. What should be checked in an API response? Status code, headers, body values / schema, response time and correct errors for bad input.
  3. Explain the hierarchy of a SoapUI project. Project → TestSuite → TestCase → TestSteps (requests, scripts, property transfers) with assertions; load tests are attached to test cases.
  4. What is Property Transfer in SoapUI? What is its Postman equivalent? Copying a value from one response (for example the new id) into later requests; in Postman, pm.environment.set / {{variable}}.
  5. Name five SoapUI assertions. Valid HTTP Status Codes, Contains, Not Contains, JSONPath Match, XPath Match (also Response SLA, Schema Compliance, Script).
  6. Explain the SoapUI load test strategies (Simple, Variance, Burst, Thread). Simple = fixed threads with a delay; Variance = threads go up and down around a value; Burst = bursts of load then rest; Thread = threads increase step by step.
  7. What do TPS, avg and err mean in SoapUI load test statistics? Transactions per second, average time in ms, and the number of failed requests.
  8. Write a Postman test that checks status 200 and a JSON field value. pm.test("ok", () => { pm.response.to.have.status(200); pm.expect(pm.response.json().name).to.eql("Asha"); });
  9. What is Newman? Postman's command-line collection runner, used in CI pipelines.

Practise this topic

Hands-on virtual lab

Apply what you just read in a realistic, guided simulation. Free with a verified account.

Create a free account to track your progress and unlock virtual labs.