Bird
0
0

What will be the output of the following test run count?

medium📝 Predict Output Q5 of 15
PyTest - Parametrize
What will be the output of the following test run count?
@pytest.mark.parametrize('x', [0, 1])
@pytest.mark.parametrize('y', [True, False])
@pytest.mark.parametrize('z', ['a', 'b'])
def test_example(x, y, z):
assert True
A8
B6
C4
D2
Step-by-Step Solution
Solution:
  1. Step 1: Count values in each parametrize decorator

    x has 2 values, y has 2 values, z has 2 values.
  2. Step 2: Calculate total test cases

    Total tests = 2 * 2 * 2 = 8.
  3. Final Answer:

    pytest runs 8 tests for all parameter combinations. -> Option A
  4. Quick Check:

    Multiply all parameter counts for total tests [OK]
Quick Trick: Multiply all parameter counts for total tests [OK]
Common Mistakes:
MISTAKES
  • Forgetting one decorator's parameters
  • Adding counts instead of multiplying
  • Assuming only two decorators count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PyTest Quizzes