Skip to content

Vedant24v/api-test-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧪 Automated API Test Framework

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.


📁 Project Structure

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

✅ Test Coverage (54 tests)

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

🚀 Setup & Run

# 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.sh

Open reports/report.html in your browser to view the full test report.


🧠 Key Concepts Demonstrated

  • 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 reportingpytest-html generates self-contained visual test reports

🛠 Tech Stack


📊 Sample Report Output

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors