Framework for automating API testing from the course "Automating REST API testing in Python" by LearnQA
Description | Prerequisites | Project Structure | Project Setup | Running tests | Viewing reports | Github workflow
- Automated CRUD (
POST
,GET
,PUT
,DELETE
) APIs usingPython
andPytest
- Continuous testing with GitHub Actions
test-automation-rest-api/
├─ .github/
│ ├─ workflows/
│ │ ├─ run_tests.yml
├─ lib
│ ├─ __init__.py/
│ ├─ assertions.py
│ ├─ base_case.py
│ ├─ logger.py
│ ├─ my_requests.py
│ ├─ schema.py
├─ logs
├─ tests/
│ ├─ __init__.py
│ ├─ test_user_auth.py
│ ├─ test_user_delete.py
│ ├─ test_user_edit.py
│ ├─ test_user_get.py
│ ├─ test_user_register.py
├─ .gitignore
├─ Dockerfile
├─ README.md
├─ docker-compose.yml
├─ environment.py
├─ pytest.ini
├─ requirements.txt
# Clone repository
git clone https://github.com/vypiemzalyubov/test-automation-rest-api.git
# Install virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run all tests
pytest tests/
# Run positive test cases
pytest -m "positive"
# Run negative test cases
pytest -m "negative"
# Run tests with "prod" environment (default "dev")
ENV=prod pytest tests/
Default startup options in
pytest.ini
:addopts = -s -v --alluredir=allure-results
# Build an image named "pytest-runner"
docker build -t pytest-runner .
# Launch the container
docker run pytest-runner
# Running with Docker Compose
docker-compose up --build
-
Install Allure from the official website
-
Generate Allure report
allure serve
-
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