Bird
0
0

Given the following DataProvider and test method, how many times will the test run?

medium📝 Predict Output Q4 of 15
Selenium Java - TestNG Integration
Given the following DataProvider and test method, how many times will the test run?
@DataProvider(name = "numbers")
public Object[][] data() {
  return new Object[][] { {1}, {2}, {3} };
}

@Test(dataProvider = "numbers")
public void testNumber(int num) {
  System.out.println(num);
}
A1 time
B3 times
C0 times
D4 times
Step-by-Step Solution
Solution:
  1. Step 1: Count data sets in DataProvider

    The DataProvider returns an Object[][] with 3 inner arrays: {1}, {2}, and {3}.
  2. Step 2: Determine test execution count

    The test method runs once per data set, so it runs 3 times, printing 1, 2, and 3 respectively.
  3. Final Answer:

    3 times -> Option B
  4. Quick Check:

    Test runs = number of data sets [OK]
Quick Trick: Test runs once per data set in Object[][] [OK]
Common Mistakes:
  • Counting inner array length incorrectly
  • Assuming test runs once regardless of data
  • Confusing number of parameters with runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes