Skip to content

Latest commit

 

History

History
124 lines (89 loc) · 2.71 KB

File metadata and controls

124 lines (89 loc) · 2.71 KB

Pytest API Automation Project

This project is prepared for the self improvement.

Tool stack

  • Python
  • Pytest
  • Requests
  • Faker

Requirements

Project Tree

.
├── README.md
├── config
│   ├── base_config.py
│   └── service
│       └── service_config.py
├── conftest.py
├── model
│   └── product.py
├── output
│   ├── assets
│   │   └── style.css
│   └── report.html
├── pytest.ini
├── requirements.txt
├── service
│   ├── carts
│   │   └── carts_service.py
│   └── products
│       └── products_service.py
├── tests
│   ├── test_customer.py
│   └── test_products.py
└── utils
    ├── api
    │   ├── api_commons.py
    │   └── api_utils.py
    ├── assertion
    │   └── assertion.py
    └── data
        └── data_generator.py

Config Folder

Used for environment variables. There are usually *_config.py files.

Model Folder

This will be used for variables implementation in the project. Variables should be defined in the class.

Service Folder

Requests to the service are managed here, methods are usually created using service utils.

Tests folder

Test files, that is, test cases in Pytest format will be located under this folder.

Utils Folder

The utils class and methods of the project will be defined in this folder.

conftest.py

File where decorators such as global fixtures are defined for pytest.

pytest.ini

Required file for pytest configuration.

requirements.txt

The file required for the installation of project necessary libraries.

output/*

Generates pytest-html reports after each execution.

Naming Convention

Conditions are requested when naming. Names should be short and meaningful.

directory names = my_directory (snake case)

variable name = my_variable (snake case)

method name = my_method (snake case)

class name = MyClass (Pascal case)

tag name = @MyTag (Pascal case)

Test Run

Python CLI command to run tests.

execution tests :

python3 -m pytest

execution tests via specific test file

python3 -m pytest 'file path'

execution tests via marks

@pytest.mark.smoke should be added in the test case

pytest -v -m smoke

execution tests via parallel

python3 -m pytest -n 4