Skip to content

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

License

Notifications You must be signed in to change notification settings

peterjpxie/REST_API_Test_Framework_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, especially reportportal.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages