Bird
0
0

What will be the result of running this parameterized test?

medium📝 Predict Output Q4 of 15
Selenium Python - Test Framework Integration (pytest)
What will be the result of running this parameterized test?
import pytest

@pytest.mark.parametrize('val', [0, 1])
def test_positive(val):
    assert val >= 0

print('Test run complete')
ANo tests run and only 'Test run complete' is printed
BTest fails for val=0 and 'Test run complete' is printed
CTest fails for val=1 and 'Test run complete' is printed
DBoth tests pass and 'Test run complete' is printed
Step-by-Step Solution
Solution:
  1. Step 1: Analyze parameter values

    Values are 0 and 1, both >= 0.
  2. Step 2: Check assertions

    assert val >= 0 passes for both inputs.
  3. Step 3: Output

    Tests pass, and print statement executes.
  4. Final Answer:

    Both tests pass and 'Test run complete' is printed -> Option D
  5. Quick Check:

    Assertions true for all inputs, print runs [OK]
Quick Trick: Assertions true for all params, print always runs [OK]
Common Mistakes:
  • Assuming 0 is negative and test fails
  • Thinking print runs before tests
  • Believing tests stop on first failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes