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!