Framework Mode - Registering markers in pytest.ini
Folder Structure
project-root/
├── tests/
│ ├── test_login.py
│ ├── test_registration.py
│ └── test_profile.py
├── pytest.ini
├── conftest.py
└── utils/
└── helpers.py
project-root/
├── tests/
│ ├── test_login.py
│ ├── test_registration.py
│ └── test_profile.py
├── pytest.ini
├── conftest.py
└── utils/
└── helpers.py
pytest.ini file where markers are registered and test settings are defined.tests/ folder containing test files using markers to categorize tests.conftest.py for shared fixtures and hooks.utils/ folder for helper functions and reusable code.The pytest.ini file is used to register custom markers to avoid warnings and improve test organization.
[pytest]
markers =
smoke: Quick smoke tests
regression: Full regression tests
slow: Tests that take longer time
This file also configures other pytest options like test paths or addopts.
Markers help filter tests in CI pipelines, e.g., run only smoke tests on every commit.
Example CI command to run smoke tests only:
pytest -m smoke --junitxml=reports/smoke-results.xml
Reports can be integrated with CI tools like Jenkins, GitHub Actions, or GitLab CI for pass/fail status and test details.
pytest.ini to avoid warnings and document their purpose.pytest.ini simple and focused on configuration only.Where in this framework structure would you add a new marker called api for tests that target API endpoints?