How would you design a maintainable Python test automation framework from scratch?
Answer
Start from the product risks and execution needs, then separate responsibilities: pytest test layer, reusable domain/page or API-client layer, fixtures and lifecycle, configuration, test-data factories, assertions, diagnostics/reporting and CI integration. Keep tests thin and business-readable, avoid one global utility module or inheritance tree that owns everything, make dependencies explicit, and design for independent local and parallel execution. A strong framework is not a folder template; its boundaries make changes, debugging and ownership predictable.
Strong answer includes
- defines clear layers for tests, interactions or clients, fixtures, data, configuration, diagnostics and CI
- keeps tests thin while avoiding god utilities and deep inheritance
- designs for isolation, parallel execution, maintainability and observable failures
Practical example
For a product with REST APIs and a browser UI, pytest owns execution; typed API clients and page/component objects expose business actions; fixtures provision users and clean state; data factories generate unique records; config is environment-driven; failure hooks attach logs/traces; CI selects smoke versus regression and runs safe subsets in parallel.