Bird
0
0

Which of the following is the correct way to mark a test function to be discovered by pytest?

easy📝 Conceptual Q2 of 15
Selenium Python - Test Framework Integration (pytest)
Which of the following is the correct way to mark a test function to be discovered by pytest?
AFunction is decorated with @pytest.mark.test
BFunction name ends with '_test'
CFunction name starts with 'test_'
DFunction is inside a class named 'Tests'
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest test discovery rules

    Pytest discovers test functions whose names start with 'test_'.
  2. Step 2: Evaluate other options

    Ending with '_test' or decorators like @pytest.mark.test are not standard discovery methods; class name 'Tests' is not required.
  3. Final Answer:

    Function name starts with 'test_' -> Option C
  4. Quick Check:

    pytest discovery = function name starts with 'test_' [OK]
Quick Trick: Name test functions starting with 'test_' for pytest discovery [OK]
Common Mistakes:
  • Using function names ending with '_test'
  • Assuming @pytest.mark.test decorator is needed
  • Thinking class name must be 'Tests'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes