Bird
0
0

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

medium📝 Predict Output Q13 of 15
Selenium Java - TestNG Integration
Given the following TestNG code, what will be the order of test execution?
@Test(priority = 2)
public void testB() { }

@Test(priority = 1)
public void testA() { }

@Test(priority = 3)
public void testC() { }
AtestA, testC, testB
BtestB, testA, testC
CtestA, testB, testC
DtestC, testB, testA
Step-by-Step Solution
Solution:
  1. Step 1: Identify priorities assigned to each test

    testA has priority 1, testB has priority 2, testC has priority 3.
  2. Step 2: Understand TestNG runs tests in ascending priority order

    Tests run from lowest priority number to highest: 1, then 2, then 3.
  3. Final Answer:

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

    Priority order = 1, 2, 3 [OK]
Quick Trick: Lower priority number runs first in TestNG [OK]
Common Mistakes:
  • Assuming higher priority number runs first
  • Ignoring priority and expecting alphabetical order
  • Confusing priority with dependsOnMethods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes