Giter VIP home page Giter VIP logo

api-testing-framework's Introduction

API Testing Framework

Python Build License MIT

It is a complete framework for automating API testing using Python and Pytest. This framework is used in the "Send Request" API.

  • CRUD methods (GET, POST, PUT and DELETE) are supported
  • Continuous testing with GitHub Actions

๐Ÿš€ Prerequisites:

Pytest HTTPX Pydantic Pydantic Settings JSONPath pytest-xdist Allure Pytest

๐Ÿš€ Project Structure:

api-testing-framework/
โ”œโ”€ .github/
โ”‚  โ”œโ”€ workflows/
โ”‚  โ”‚  โ”œโ”€ run.yml
โ”œโ”€ api
โ”‚  โ”œโ”€ sendrequest_api/
โ”‚  |  โ”œโ”€ auth_client.py
โ”‚  |  โ”œโ”€ companies_client.py
โ”‚  |  โ”œโ”€ issues_client.py
โ”‚  |  โ”œโ”€ users_client.py
โ”‚  โ”œโ”€ api_client.py
โ”‚  โ”œโ”€ routes.py
โ”œโ”€ fixtures
โ”‚  โ”œโ”€ auth_fixture.py
โ”‚  โ”œโ”€ companies_fixture.py
โ”‚  โ”œโ”€ issues_fixture.py
โ”‚  โ”œโ”€ users_fixture.py
โ”œโ”€ tests/
โ”‚  โ”œโ”€ __init__.py
โ”‚  โ”œโ”€ test_auth.py
โ”‚  โ”œโ”€ test_companies.py
โ”‚  โ”œโ”€ test_issues.py
โ”‚  โ”œโ”€ test_users.py
โ”œโ”€ utils
โ”‚  โ”œโ”€ data/
โ”‚  |  โ”œโ”€ load.py
โ”‚  โ”œโ”€ models/
โ”‚  |  โ”œโ”€ auth_model.py
โ”‚  |  โ”œโ”€ companies_model.py
โ”‚  |  โ”œโ”€ users_model.py
โ”‚  โ”œโ”€ asserts.py
โ”‚  โ”œโ”€ logger.py
โ”‚  โ”œโ”€ parser.py
โ”œโ”€ .env
โ”œโ”€ .gitignore
โ”œโ”€ .pylintrc
โ”œโ”€ conftest.py
โ”œโ”€ docker-compose.yml
โ”œโ”€ Dockerfile
โ”œโ”€ LICENSE
โ”œโ”€ pytest.ini
โ”œโ”€ README.md
โ”œโ”€ requirements.txt
โ”œโ”€ settings.py

๐Ÿš€ Getting Started

# Clone repository
git clone https://github.com/vypiemzalyubov/api-testing-framework.git

# Install virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

๐Ÿš€ Running tests

# Run all tests
pytest tests/

# Run positive test cases
pytest -m "positive"

# Run negative test cases
pytest -m "negative"

Default startup options in pytest.ini:

addopts = 
       -s -v
       --tb=short
       --alluredir=allure-results

๐Ÿš€ Viewing reports

  • Install Allure from the official website

  • Generate Allure report

    allure serve

๐Ÿš€ Running in Docker

# Build an image named "api-testing-runner"
docker build -t api-testing-runner .

# Launch the container
docker run api-testing-runner

# Running with Docker Compose
docker-compose up --build

๐Ÿš€ Github workflow

  • Go to "Run workflow" in GitHub Actions

    # Options in workflow
      - all_tests
      - positive_tests
      - negative_tests
  • View Allure test results after completing the GitHub Actions workflow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.