A Postman collection for end-to-end testing of a Library REST API. It covers the full lifecycle of a book record — adding, retrieving, and deleting — with automated test assertions at every step.
- Collection Overview
- Prerequisites & Setup
- Execution Workflow
- Requests
- Variables
- How to Run
- Test Coverage Summary
- Notes
| Property | Value |
|---|---|
| Collection Name | Library |
| Base URL | {{base_url}} (e.g. http://216.10.245.166) |
| Total Requests | 3 |
| Total Tests | 15 assertions |
| Environment | QA |
| Execution Order | Sequential (AddBook → GetBook → DeleteBook) |
- Import the collection into Postman.
- Import the QA environment and set it as the active environment.
- Set the Global variable
CompanyCodeto your desired prefix (default:RS). - Ensure the Library API server is reachable at the
base_url.
The requests are designed to run sequentially in this order:
AddBook ──► GetBook ──► DeleteBook
│ │ │
│ Sets │ Validates │ Deletes
│ book_id ────┘ book data │ by book_id
└──────────────────────────────►┘
- AddBook creates a new book and saves the returned
IDto thebook_idenvironment variable. - GetBook uses
book_idto fetch and validate the book details. - DeleteBook uses
book_idto delete the book and confirms deletion.
| Property | Value |
|---|---|
| Method | POST |
| URL | {{base_url}}/Library/Addbook.php |
Request Body (JSON):
{
"name": "Learn Appium Automation with Java",
"isbn": "{{isbn}}",
"aisle": "2278899",
"author": "{{author_name}}"
}Pre-Request Script:
- Reads
CompanyCodefrom global variables (e.g.RS). - Generates a random integer using
{{$randomInt}}. - Concatenates them to form a unique
isbn(e.g.RS4821) and sets it as a collection variable. - Sets
author_namecollection variable to"Rahul Shetty".
const code = pm.globals.get("CompanyCode");
const val = pm.variables.replaceIn('{{$randomInt}}');
pm.collectionVariables.set("isbn", code + val);
pm.collectionVariables.set("author_name", "Rahul Shetty");Test Assertions:
- ✅ Status code is
200 - ✅ Response message is
"successfully added" - ✅ Returned
IDincludes theisbnvalue - ✅
Content-Typeheader isapplication/json;charset=UTF-8 - ✅ Response time is below
2000ms - ✅ ID concatenation logic:
isbn + aisle === returned ID - ✅ Saves returned
IDto environment variablebook_id
| Property | Value |
|---|---|
| Method | GET |
| URL | {{base_url}}/Library/GetBook.php |
| Query Param | ID = {{book_id}} |
Test Assertions:
- ✅ Status code is
200 - ✅ Response matches JSON schema (array of objects with
book_name,isbn,aisle,author) - ✅
authormatches collection variableauthor_name - ✅
isbnmatches collection variableisbn - ✅
book_nameis"Learn Appium Automation with Java" - ✅
aisleis"2278899"
JSON Schema Validated:
{
"type": "array",
"items": {
"type": "object",
"required": ["book_name", "isbn", "aisle", "author"],
"properties": {
"book_name": { "type": "string" },
"isbn": { "type": "string" },
"aisle": { "type": "string" },
"author": { "type": "string" }
}
}
}| Property | Value |
|---|---|
| Method | POST |
| URL | {{base_url}}/Library/DeleteBook.php |
Request Body (JSON):
{
"ID": "{{book_id}}"
}Test Assertions:
- ✅ Status code is
200 - ✅ Response message is
"book is successfully deleted"
Set these in the QA environment before running the collection.
| Variable | Example Value | Description |
|---|---|---|
base_url |
http://216.10.245.166 |
Base URL of the Library API server |
book_id |
RS4822278899 |
Book ID returned by AddBook; automatically set by the AddBook post-response script. Used by GetBook and DeleteBook. |
url |
http://216.10.245.166 |
Alternate URL variable (same as base_url) |
These are workspace-wide variables shared across all collections.
| Variable | Example Value | Description |
|---|---|---|
CompanyCode |
RS |
Prefix used to generate the isbn. Prepended to a random integer (e.g. RS + 4821 = RS4821). |
access_token |
<token> |
OAuth access token used for authenticated requests in other collections. |
These are set dynamically at runtime by the pre-request script of AddBook.
| Variable | Set By | Example Value | Description |
|---|---|---|---|
isbn |
AddBook pre-request | RS4821 |
Generated as CompanyCode + random integer. Used in the request body and validated in tests. |
author_name |
AddBook pre-request | Rahul Shetty |
Author name used in the request body and validated in GetBook tests. |
- Open the Library collection in Postman.
- Click Run collection.
- Select the QA environment.
- Ensure the request order is:
AddBook → GetBook → DeleteBook. - Click Run Library.
# Install Newman
npm install -g newman
# Run the collection
newman run Library.postman_collection.json \
--environment QA.postman_environment.json \
--globals globals.json| Request | Assertions | What's Validated |
|---|---|---|
| AddBook | 7 | Status code, response message, ID format, Content-Type header, response time, ID concatenation logic, book_id saved to env |
| GetBook | 6 | Status code, JSON schema, author, isbn, book_name, aisle |
| DeleteBook | 2 | Status code, deletion confirmation message |
| Total | 15 |
- 🔗 Sequential execution is required. AddBook must run before GetBook and DeleteBook, as
book_idis set dynamically. - 🎲 Dynamic ISBN generation ensures each test run uses a unique book, preventing conflicts.
- 🔄 Variable chaining:
CompanyCode(global) →isbn(collection) →book_id(environment) flows across all three requests automatically. - 📊 Data-driven testing is supported. The pre-request script has commented-out lines to read
BookNameandAuthorfrom iteration data files for bulk testing via the Collection Runner. - 🌍 Environment isolation: Using the QA environment keeps test data separate from other environments.