Bird
0
0

For a large pytest project with multiple components, which test organization approach is considered best practice?

hard🚀 Application Q8 of 15
PyTest - Basics and Setup
For a large pytest project with multiple components, which test organization approach is considered best practice?
APlace all test files flat inside a single <code>tests/</code> folder without subfolders
BCreate separate subdirectories inside <code>tests/</code> for each component or module
CMix test files with source code files in each module folder
DStore tests in a single file named <code>all_tests.py</code>
Step-by-Step Solution
Solution:
  1. Step 1: Consider scalability

    Large projects benefit from modular test organization to keep tests manageable.
  2. Step 2: Evaluate options

    Create separate subdirectories inside tests/ for each component or module organizes tests by component, improving clarity and selective test runs.
  3. Final Answer:

    Create separate subdirectories inside tests/ for each component or module -> Option B
  4. Quick Check:

    Use subfolders in tests/ for modular test organization [OK]
Quick Trick: Organize tests in subfolders by module/component [OK]
Common Mistakes:
MISTAKES
  • Keeping all tests in one flat folder
  • Mixing tests with source code files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes