Framework Mode - Running tests by marker (-m)
Folder Structure
project-root/
├── tests/
│ ├── test_login.py
│ ├── test_signup.py
│ ├── test_profile.py
│ └── __init__.py
├── pytest.ini
├── conftest.py
└── utils/
└── helpers.py
project-root/
├── tests/
│ ├── test_login.py
│ ├── test_signup.py
│ ├── test_profile.py
│ └── __init__.py
├── pytest.ini
├── conftest.py
└── utils/
└── helpers.py
Use pytest.ini to declare custom markers to avoid warnings and organize tests:
[pytest]
markers =
smoke: quick smoke tests
regression: full regression tests
slow: tests that take longer time
Run tests by marker using the -m option:
pytest -m smoke
This runs only tests marked with @pytest.mark.smoke.
Combine markers with and, or, and not:
pytest -m "smoke and not slow"
Use environment variables or command line options to select markers dynamically if needed.
pytest -m smoke --junitxml=reports/smoke-results.xml
pytest.ini to keep the framework clean and avoid warnings.and, or, and not to fine-tune test selection.Where in this folder structure would you add a new test file for API tests that you want to mark as regression?