A production-style API testing framework built with Python, pytest, and pytest-html, targeting the JSONPlaceholder REST API.
Demonstrates real-world QA engineering practices: functional testing, negative/edge case testing, schema validation, cross-resource integrity checks, and performance assertions.
api-test-framework/
├── config.py # Base URLs, endpoints, schema definitions
├── requirements.txt
├── pytest.ini # Test discovery & reporting config
├── run_tests.sh # One-command runner
├── utils/
│ └── helpers.py # Reusable HTTP wrappers & assertion helpers
├── tests/
│ ├── conftest.py # Shared pytest fixtures (session-scoped)
│ ├── test_posts.py # Functional tests: GET / POST / PUT / DELETE
│ ├── test_edge_cases.py # Negative tests: 404s, invalid IDs, bad payloads
│ ├── test_users_todos.py # Integration tests: schema, cross-resource integrity
│ └── test_performance.py # Response time assertions with latency reporting
└── reports/
└── report.html # Auto-generated HTML test report
| Suite | What's Tested |
|---|---|
test_posts.py |
GET all/by-ID, filter, POST create, PUT update, DELETE, schema, content-type |
test_edge_cases.py |
404 for missing IDs, zero/negative IDs, string IDs, empty/partial/extra payloads, boundary values, comment integrity |
test_users_todos.py |
User schema + nested objects, email format, unique IDs, todo boolean fields, cross-resource userId integrity |
test_performance.py |
Response time < 3s per endpoint, latency logging for all main routes |
# 1. Clone
git clone https://github.com/Vedant24v/api-test-framework
cd api-test-framework
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run all tests with HTML report
pytest --html=reports/report.html --self-contained-html -v
# OR use the one-command runner
bash run_tests.shOpen reports/report.html in your browser to view the full test report.
- Modular architecture — config, helpers, fixtures, and tests are fully separated
- Session-scoped fixtures — API calls shared across tests to avoid redundant requests
- Schema validation — assert exact key sets on every resource type
- Negative testing — explicitly verify error behavior (404s, bad input, boundary values)
- Cross-resource integrity — verify relational consistency across
/posts,/users,/todos - Performance testing — enforce response time SLAs with human-readable latency reports
- HTML reporting —
pytest-htmlgenerates self-contained visual test reports
- Python 3.x
- pytest — test runner
- requests — HTTP client
- pytest-html — HTML report generation
tests/test_posts.py::TestGetPosts::test_get_all_posts_returns_200 PASSED
tests/test_posts.py::TestGetPosts::test_get_all_posts_count PASSED
tests/test_posts.py::TestCreatePost::test_create_post_returns_201 PASSED
tests/test_edge_cases.py::TestNotFound::test_get_nonexistent_post PASSED
tests/test_edge_cases.py::TestBoundaryValues::test_get_last_post PASSED
tests/test_users_todos.py::TestCrossResourceIntegrity::... PASSED
tests/test_performance.py::TestResponseTimes::test_response_time_logged
--- Response Time Report ---
✅ PASS GET /posts 0.312s
✅ PASS GET /posts/1 0.198s
✅ PASS GET /users 0.245s
✅ PASS GET /users/1 0.187s
----------------------------
54 passed in 6.3s