Bird
0
0

Consider this TestNG code:

medium📝 Predict Output Q5 of 15
Selenium Java - TestNG Integration
Consider this TestNG code:
@Test public void testA() { Assert.assertTrue(false); }
@Test(dependsOnMethods = {"testA"}) public void testB() { Assert.assertTrue(true); }

What will be the outcome of testB?
AtestB passes because it runs independently.
BtestB fails because testA failed.
CtestB runs before testA.
DtestB is skipped because testA failed.
Step-by-Step Solution
Solution:
  1. Step 1: Check testA result

    testA asserts false, so it fails.
  2. Step 2: Check testB dependency effect

    Since testB depends on testA and testA failed, testB is skipped by TestNG.
  3. Final Answer:

    testB is skipped because testA failed. -> Option D
  4. Quick Check:

    Failed dependency causes skip = D [OK]
Quick Trick: Failed dependencies skip dependent tests automatically [OK]
Common Mistakes:
MISTAKES
  • Assuming dependent tests run despite failure
  • Confusing skip with fail
  • Thinking testB runs before testA

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes