Bird
0
0

Given the following TestNG code:

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

What will be the test execution result?
ABoth testA and testB pass.
BtestA fails, testB is skipped.
CtestA passes, testB fails.
DBoth testA and testB are skipped.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze testA execution

    testA asserts true, so it passes successfully.
  2. Step 2: Analyze testB execution

    testB depends on testA, which passed, so testB runs and asserts false, causing failure.
  3. Final Answer:

    testA passes, testB fails. -> Option C
  4. Quick Check:

    Dependency passed, dependent test runs and fails = B [OK]
Quick Trick: Dependent tests run only if dependencies pass [OK]
Common Mistakes:
MISTAKES
  • Assuming testB is skipped if it fails
  • Thinking testA fails due to testB failure
  • Confusing pass/fail order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes