Professional API testing framework using Postman collections and Newman CLI automation for the JSONPlaceholder REST API.
This project demonstrates:
- ✅ Professional API testing with Postman
- ✅ Multi-environment testing (Dev, QA, Staging)
- ✅ CLI automation with Newman
- ✅ HTML reporting with newman-reporter-htmlextra
- ✅ Organized test suites with clear structure
- ✅ CI/CD ready architecture
This is NOT just running Postman tests.
This IS a complete testing framework for API validation.
postman-newman-api-testing/
├── collections/
│ └── JSONPlaceholder_API_Tests.postman_collection.json
├── environments/
│ ├── JSONPlaceholder-Dev.postman_environment.json
│ ├── JSONPlaceholder-QA.postman_environment.json
│ └── JSONPlaceholder-Staging.postman_environment.json
├── reports/ # Generated HTML reports
├── docs/ # Documentation
├── .gitignore
├── package.json
└── README.md
API Under Test: JSONPlaceholder
| Test Suite | Requests | Assertions | Status |
|---|---|---|---|
| 1. GET Operations | 2 | 12 | ✅ |
| 2. POST Operations | 1 | 5 | ✅ |
| 3. PUT/PATCH Operations | 1 | 5 | ✅ |
| 4. DELETE Operations | 1 | 3 | ✅ |
| 5. Negative Tests | 3 | 7 | ✅ |
| Total | 8 requests | 32 assertions | 100% |
Positive Tests:
- ✅ Get all posts
- ✅ Get single post by ID
- ✅ Create new post
- ✅ Update existing post
- ✅ Delete post
- ✅ Response time validation (< 2000ms)
Negative Tests:
- ❌ 404 - Post not found
- ❌ Missing required fields
- ❌ Invalid data handling
- Clone the repository:
git clone https://github.com/your-username/postman-newman-api-testing.git
cd postman-newman-api-testing- Install dependencies:
npm install- Verify installation:
npx newman --version
# Should show: newman/6.x.xThe project uses cross-platform NPM scripts to run the tests.
npm run test:dev
npm run test:qa
npm run test:stagingThis will run the full test suite in the specified environment and automatically generate an HTML report in the reports/ folder.
npm run test:allnpm run test:smokeRuns only the GET Operations folder for quick validation.
Basic run:
npx newman run collections/JSONPlaceholder_API_Tests.postman_collection.json \
-e environments/JSONPlaceholder-Dev.postman_environment.json- Base URL:
https://jsonplaceholder.typicode.com - Purpose: Local development testing
- Variables:
base_url,post_id,environment
- Base URL:
https://jsonplaceholder.typicode.com - Purpose: QA environment validation
- Variables:
base_url,post_id,environment
- Base URL:
https://jsonplaceholder.typicode.com - Purpose: Pre-production testing
- Variables:
base_url,post_id,environment,timeout
Note: In a real project, each environment would have different URLs.
┌─────────────────────────┬───────────────────┬───────────────────┐
│ │ executed │ failed │
├─────────────────────────┼───────────────────┼───────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ requests │ 8 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ assertions │ 32 │ 0 │
└─────────────────────────┴───────────────────┴───────────────────┘
Open reports/[env]-report-[timestamp].html in browser for:
- ✅ Visual test results dashboard
- ✅ Request/response details
- ✅ Execution timeline
- ✅ Performance metrics
- ✅ Pass/fail statistics
Tests are organized in numbered folders for sequential execution:
1. POST - GET/
├── Get all Requests # Lists all posts
└── Get Single Post # Retrieves post by ID
2. Posts - POST/
└── Create New Post # Creates a new post
3. Posts - PUT/PATCH/
└── Update Post (PUT) # Updates existing post
4. Posts - DELETE/
└── Delete Post # Deletes a post
5. Negative Tests/
├── Get Post - Not Found # 404 handling
├── Create Post - Missing Body # Validation
└── Delete Post - Not Found # Error handling
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});pm.test("Response time is less than 2000ms", function () {
pm.expect(pm.response.responseTime).to.be.below(2000);
});pm.test("Response is an array", function () {
const jsonData = pm.response.json();
pm.expect(jsonData).to.be.an("array");
});
pm.test("Post has correct structure", function () {
const post = pm.response.json()[0];
pm.expect(post).to.have.property("userId");
pm.expect(post).to.have.property("id");
pm.expect(post).to.have.property("title");
pm.expect(post).to.have.property("body");
});API Testing:
- RESTful API validation
- HTTP methods (GET, POST, PUT, DELETE)
- Status code verification
- Response validation
- Error handling
Automation:
- Newman CLI usage
- Environment management
- Batch scripting
- Report generation
Quality Assurance:
- Test organization
- Positive/negative testing
- Regression testing
- Multi-environment validation
- Open collection in Postman
- Add new request to appropriate folder
- Write test scripts in "Tests" tab
- Export collection (v2.1)
- Replace
collections/JSONPlaceholder_API_Tests.postman_collection.json
- Create environment in Postman
- Add required variables (
base_url, etc.) - Export environment
- Save to
environments/folder - Update scripts to include new environment
- Add data-driven testing with CSV/JSON
- Implement CI/CD with GitHub Actions
- Add performance testing scenarios
- Create custom Newman reporter
- Add authentication testing (OAuth, JWT)
- Integrate with test management tools
- GitHub: https://github.com/ChandeDeVargas
- LinkedIn: https://www.linkedin.com/in/chande-de-vargas-b8a51838a/
This project is open source and available under the MIT License.
⭐ If this project helped you learn Postman and Newman, give it a star!