What if you could run just the tests you need with one simple command?
Why Running tests by marker (-m) in PyTest? - Purpose & Use Cases
Imagine you have a big set of tests for your app. You want to run only the tests about login, but you have to open each test file and run them one by one.
This manual way is slow and tiring. You might forget some tests or run the wrong ones. It wastes time and can cause mistakes.
Using markers with -m lets you tag tests and run just the ones you want with one simple command. It saves time and keeps things organized.
pytest tests/test_login.py
grep 'def test_login' tests/test_login.py | xargs pytestpytest -m login
You can quickly run focused groups of tests anytime, making testing faster and smarter.
When fixing a bug in the payment system, you run only payment tests marked with @pytest.mark.payment to check your fix without waiting for all tests.
Manual test selection is slow and error-prone.
Markers let you tag and run specific test groups easily.
Running tests by marker speeds up your workflow and reduces mistakes.