This project is a pytest based framework using python's request pacakge designed for api testing. It follows a modular structure and includes packages for libs, tests and features.
-
api_auto (root folder) The root folder contains the entire project structure:
-
lib:
- dataprovider:
- json test data under directories based on env e.g: live > user.json
- has a data_provider singleton to parse static data
- models to map the test data to. (User, Account)
- handle between static and dynamic data
- logger:
- use for logging - currently only used for info logs
- api_service_provider:
- api_service : singleton wrapper for http requests & used for session management.
- services : e.g account, user - children of api_service calling api_service
- api_constants : paths etc stored.
- utils:
- constants - for overall project
- helpers = wrapper and data generator methods
- dataprovider:
-
features:
- Call Hierarchy: Tests > (Features) > lib
- Functionality wise
- logic implementation for different features/ scenarios/ use cases
-
tests:
- Test scripts for different scenarios
- baseCase - parent of all tests.
-
reports:
- using pytest-html package, easy to setup as descried below.
-
conftest:
- update pytest run configuration for request session management
-
- Tests can call features and lib (dataprovider, api_provider etc)
- Its better to move assertions outside of tests (WIP)
Pre-requisite
python 3 or aboveClone the repo.
git clone git@github.com:sajManzoor/api_auto.git Create a python virtual environment:
python3 -m venv venv
source venv/bin/activateInstall all requirements:
pip install -r requirements.txtRun all tests:
pytest path/to/testsRun all tests and generate reports:
pytest tests --html=reports/test_run.html