Overview - Conftest for shared fixtures
What is it?
Conftest is a special Python file used in pytest to define fixtures that can be shared across multiple test files. Fixtures are reusable pieces of setup code that prepare the environment for tests, like opening a browser or setting test data. By placing fixtures in conftest.py, you avoid repeating the same setup in every test file. This makes tests cleaner and easier to maintain.
Why it matters
Without shared fixtures in conftest.py, you would have to copy the same setup code into every test file, which wastes time and causes errors if you forget to update one place. Shared fixtures help keep tests consistent and reduce bugs caused by setup mistakes. This saves time and effort when running many tests, especially in Selenium where browser setup is common.
Where it fits
Before learning conftest fixtures, you should understand basic pytest fixtures and how Selenium tests work. After mastering conftest, you can learn about pytest plugins, parameterized fixtures, and advanced test organization techniques.