Modul 9 · Python for SDETs

Hesabat &
dəst quruluşu

Dəsti komanda üçün oxunaqlı et — bölüşülə bilən hesabatlar, marker-lər, qovluqlar

pytest-html marker-lər sahə başına conftest darvaza əmri
AI with Rufat
Tək bölüşülə bilən hesabat faylı
bash
# install once, then re-pin
pip install pytest-html
pip freeze > requirements.txt
pytest --html=report.html \
--self-contained-html
📄Hər testi siyahılayır — nəticə, müddət, tutulmuş çıxış, uğursuz traceback-lər inline.
📎--self-contained-html CSS/JS-i inline edir, ona görə o bir fayl email edilə və ya CI artefaktı kimi yüklənə bilir.
AI with Rufat
Bir alt-dəst etiketlə, yalnız o alt-dəsti işlət
# pytest.ini
[pytest]
markers =
smoke: fast, critical subset
api: hits the REST API
ui: drives the browser
@pytest.mark.smoke
def test_products_up(): …
pytest -m smoke
pytest -m "api and not smoke"
pytest -m ui
🚦-m and/or/not dəstəkləyir. Saniyələrlik smoke alt-dəsti sənin gündəlik "kritik nəyisə sındırdıqmı?" darvazandır.
AI with Rufat
Sahəyə görə qruplaşdır, fixture-ləri qovluqla bölüş
tests/
├── conftest.py # shared
├── api/
│ ├── conftest.py
│ └── test_products.py
└── ui/
├── conftest.py
└── test_login.py
🗂️pytest bir testə gedən yoldakı hər conftest.py-i yükləyir — import yoxdur.
🎯Yuxarı conftest.py = bölüşülən fixture-lər (hər yerdə); iç-içə biri = o sahəyə scope-lanmış. Mərkəzi bölüşülən, lokal xas.
AI with Rufat
Oxunaqlı giriş, oxunaqlı çıxış

Bir əmr: sürətli alt-dəst · artefakt · təmiz xülasə

pytest -m smoke --html=smoke-report.html \
--self-contained-html -ra --tb=short
-m smoke sürətli alt-dəst
--html artefakt
-ra skip/xfail
--tb=short yığcam
🧾Həmçinin əlverişli: --durations=10 (ən yavaş testlər) və -q (test başına bir simvol). Modul 10 məhz bu darvazanı GitHub Actions-a qoşur.
AI with Rufat
🧾

Komandanın
oxuya bildiyi dəst

Bölüşülə bilən hesabatlar, bir smoke darvazası və onlarla faylı keçib miqyaslanan qovluq quruluşu

📄
Məşq
report.html yarat və bir testin müddətini və nəticəsini tap
🚦
Smoke darvazası
İki sürətli testi etiketlə və yalnız pytest -m smoke işlət
➡️
Modul 10
CI — dəsti GitHub Actions ilə hər push-da işlət
AI with Rufat
← / → · space