Skip to content

Automated API testing framework using Python, pytest, and requests. Features 9 comprehensive tests covering CRUD operations, negative testing, performance validation, and data-driven testing.

Notifications You must be signed in to change notification settings

simarpal-93/API-Testing-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Testing Automation Project

Overview

This project demonstrates automated API testing using Python, pytest, and the requests library. It tests the ReqRes API endpoints with various test scenarios including positive and negative test cases.

Technologies Used

  • Python 3.14
  • pytest - Testing framework
  • requests - HTTP library for API calls
  • pytest-html - HTML report generation

Project Structure

QA-Testing/
├── tests/
│   ├── __init__.py
│   └── test_cases/
│       ├── __init__.py
│       └── test_users.py
├── reports/
│   └── test_report.html
├── venv/
├── requirements.txt
└── README.md

Setup Instructions

1. Clone the repository

git clone <your-repo-url>
cd QA-Testing

2. Create virtual environment

python3 -m venv venv
source venv/bin/activate  # On Mac/Linux
# OR
venv\Scripts\activate  # On Windows

3. Install dependencies

pip install -r requirements.txt

4. Run tests

# Run all tests
pytest tests/test_cases/test_users.py -v

# Run with detailed output
pytest tests/test_cases/test_users.py -v -s

# Generate HTML report
pytest tests/test_cases/test_users.py --html=reports/test_report.html --self-contained-html

Test Coverage

1. Get Single User (Positive Test)

  • Endpoint: GET /api/users/2
  • Validates: Status code 200, user ID, email field

2. Get List of Users (Positive Test)

  • Endpoint: GET /api/users?page=2
  • Validates: Status code 200, data list not empty, pagination

3. User Not Found (Negative Test)

  • Endpoint: GET /api/users/999
  • Validates: Status code 404 for non-existent user

4. Create User (POST Request)

  • Endpoint: POST /api/users
  • Validates: Status code 201, response fields (name, job, id, createdAt)

Key Features

  • ✅ Automated API testing
  • ✅ Positive and negative test scenarios
  • ✅ API authentication with headers
  • ✅ Detailed HTML test reports
  • ✅ Clean, maintainable code structure
  • ✅ Comprehensive assertions

API Authentication

This project uses ReqRes API which requires an API key:

HEADERS = {
    "x-api-key": "reqres-free-v1"
}

Test Results

All tests passing with 100% success rate. See reports/test_report.html for detailed results.

Future Enhancements

  • Add more test cases (PUT, PATCH, DELETE)
  • Implement data-driven testing
  • Add API response time validation
  • Integrate with CI/CD pipeline
  • Add test data management

Author

Simarpal Singh

License

This project is for educational purposes.

About

Automated API testing framework using Python, pytest, and requests. Features 9 comprehensive tests covering CRUD operations, negative testing, performance validation, and data-driven testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published