Overview - Running tests by marker (-m)
What is it?
Running tests by marker (-m) in pytest means selecting and executing only those tests that have a specific label or tag called a marker. Markers are special keywords you add to tests to group or categorize them. Using the -m option lets you run tests with certain markers without running the entire test suite. This helps focus on relevant tests quickly.
Why it matters
Without the ability to run tests by marker, you would have to run all tests every time, which wastes time and resources. Markers let you organize tests by features, bug fixes, or test types, so you can run just what you need. This speeds up development and debugging, making testing more efficient and manageable.
Where it fits
Before learning about running tests by marker, you should understand basic pytest test creation and execution. After this, you can learn about advanced pytest features like test parametrization, fixtures, and custom markers to further organize and optimize tests.