Bird
0
0

What is the main purpose of the @pytest.mark.parametrize decorator in pytest?

easy🧠 Conceptual Q11 of 15
PyTest - Parametrize
What is the main purpose of the @pytest.mark.parametrize decorator in pytest?
ATo skip a test function during test execution
BTo run the same test function multiple times with different input values
CTo mark a test as expected to fail
DTo group multiple test functions into a test suite
Step-by-Step Solution
Solution:
  1. Step 1: Understand the decorator's role

    @pytest.mark.parametrize allows running one test function multiple times with different inputs.
  2. Step 2: Compare options with this role

    Only To run the same test function multiple times with different input values describes running the same test with different inputs, matching the decorator's purpose.
  3. Final Answer:

    To run the same test function multiple times with different input values -> Option B
  4. Quick Check:

    Parametrize = multiple inputs [OK]
Quick Trick: Parametrize means run test many times with different data [OK]
Common Mistakes:
MISTAKES
  • Confusing parametrize with skipping tests
  • Thinking it groups tests instead of repeating one
  • Mixing it up with marking expected failures

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes