โ† Back to Projects
View Project on GitHub

Tech Stack

Language

Python

Framework

PytestRequests

Reporting

Allure Reports

Cicd

Jenkins

๐Ÿš€ Building a Robust API Test Automation Framework with Python

๐ŸŽฏ Introduction

Hey there, fellow automation enthusiasts! ๐Ÿ‘‹ Ready to dive into something exciting? Today, I'm going to walk you through our super-cool API testing framework that I've built using Python. It's like having a Swiss Army knife for API testing - versatile, reliable, and surprisingly elegant!

๐ŸŽฎ What's in it for You?

Before we dive deep, here's what you're going to get:

  1. ๐Ÿ—๏ธ A rock-solid, maintainable testing framework
  2. ๐Ÿ“ Beautiful logging that actually makes sense
  3. ๐ŸŒ Support for all your environments (staging, prod, UAT)
  4. โœจ Super easy test case creation
  5. ๐Ÿ“Š Test results that tell a story

๐Ÿฐ Architecture Overview

Our architecture follows a modular design pattern that makes it highly maintainable, readable, and extensible. Think of our framework as a well-organized castle, where each component has its specific role:

Framework Architecture

Framework Layers Explained

  1. Base API Layer ๐ŸŒ

    • The foundation that handles all HTTP communications
    • Implements wrappers for REST calls (GET, POST, PUT, DELETE)
    • Manages request/response lifecycles and error handling
    • Located in Core/base_api.py
  2. API Player Layer ๐ŸŽฎ

    • Orchestrates test actions and manages test state/context
    • Interfaces directly with endpoint classes through composition
    • Contains business logic and test-oriented wrappers
    • Formats requests, processes responses, and handles errors
    • Maintains session information and authentication
    • Located in Core/api_player.py
  3. Endpoints Layer ๐Ÿ”Œ

    • Abstracts the endpoints of the application under test
    • One class per feature area (e.g., CarsAPIEndpoints, RegistrationAPIEndpoints)
    • Maps directly to the application's API structure
    • No business logic, only endpoint definitions and basic request formatting
    • Located in Endpoints directory
  4. Results Tracking Layer ๐Ÿ“Š

    • Tracks test outcomes and provides detailed reporting
    • Manages logging and result collection
    • Helps generate meaningful test reports
    • Located in Utils/results.py