Crystalchu / REST_API_Test_Framework_Python

REST API Test Framework example using Python requests and flask for both functional and performance tests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A RESTful API Test Framework Example

Code style: black

Features:

  • Support both functional and performance tests
  • Test by parametrized input / output text files
  • Use flask to mock API services dynamically with magic
  • HTML report
  • Common get/post/request functions to:
    1. Print every request and response in an API output file
    2. Append common headers
    3. Handle request exceptions and non-20X response codes, so you only need to focus on normal json response.

Install:

pip install -r Scripts/requirements.txt

Run:

cd Scripts

Start API mock services:

python flask_mock_service.py

Run Functional tests:

pytest

Run Performance tests:

python perf_test_rest_api.py

Medium Post

Check out the medium post for more details.

HTML Report

For HTML report generation, we are using pytest-html which is simple and effective.

Other alternatives to generate fancier HTML reports are Allure and reportportal. Note these report frameworks are heavy, espcially reportportal.

About

REST API Test Framework example using Python requests and flask for both functional and performance tests.

License:MIT License


Languages

Language:Python 99.8%Language:Shell 0.2%Language:Batchfile 0.0%