- --collect-only
- -m
- @pytest.mark
PyTest select tests by marker
- Use the @pytest.mark.name decorator to tag the tests.
examples/pytest/markers/test_by_marker.py
import pytest @pytest.mark.smoke def test_database_read(): assert True @pytest.mark.security @pytest.mark.smoke def test_database_write(): assert True @pytest.mark.security def test_database_forget(): assert True @pytest.mark.smoke def test_ui_access(): assert True @pytest.mark.security def test_ui_forget(): assert True
pytest --collect-only -m security test_by_marker.py test_ui_forget test_database_write test_database_forget
pytest --collect-only -m smoke test_by_marker.py test_database_read test_ui_access test_database_write