Bird
0
0

Given the following TestNG code, what will be the order of test execution?

medium📝 Predict Output Q4 of 15
Selenium Java - TestNG Integration
Given the following TestNG code, what will be the order of test execution?
@Test(priority=3) public void testA() {}
@Test(priority=1) public void testB() {}
@Test(priority=2) public void testC() {}
AtestC, testB, testA
BtestA, testB, testC
CtestB, testC, testA
DtestB, testA, testC
Step-by-Step Solution
Solution:
  1. Step 1: Understand priority ordering in TestNG

    Lower priority values run first. So priority=1 runs before 2, which runs before 3.
  2. Step 2: Order tests by priority values

    testB has priority 1, testC priority 2, testA priority 3, so order is testB, testC, testA.
  3. Final Answer:

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

    Priority ascending order = C [OK]
Quick Trick: Lower priority number runs first in TestNG [OK]
Common Mistakes:
  • Assuming higher priority runs first
  • Ignoring priority and running alphabetically
  • Mixing up priority values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes