Bird
0
0

Identify the error in the following DataProvider usage:

medium📝 Debug Q14 of 15
Selenium Java - TestNG Integration
Identify the error in the following DataProvider usage:
@DataProvider(name = "inputData")
public Object[] data() {
    return new Object[] {"A", "B"};
}

@Test(dataProvider = "inputData")
public void testMethod(String input) {
    System.out.println(input);
}
ADataProvider method should return Object[][], not Object[]
BTest method parameter type is incorrect
CMissing @Test annotation on DataProvider method
DDataProvider name does not match test method
Step-by-Step Solution
Solution:
  1. Step 1: Check DataProvider return type

    DataProvider methods must return Object[][] to supply multiple parameter sets.
  2. Step 2: Identify mismatch in return type

    The method returns Object[], which is invalid and causes runtime errors.
  3. Final Answer:

    DataProvider method should return Object[][], not Object[] -> Option A
  4. Quick Check:

    DataProvider return type = Object[][] [OK]
Quick Trick: DataProvider must return Object[][], not Object[] [OK]
Common Mistakes:
MISTAKES
  • Returning Object[] instead of Object[][]
  • Confusing test method parameter types
  • Forgetting to match DataProvider name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes