Recall & Review
beginner
What is a Data Provider in Selenium Java testing?
A Data Provider is a method that supplies test data to a test method, allowing the same test to run multiple times with different inputs.
Click to reveal answer
beginner
How do you annotate a Data Provider method in TestNG?
You use the @DataProvider annotation above the method that returns an Object[][] or Iterator containing test data.
Click to reveal answer
beginner
Why use Data Providers instead of hardcoding test data?
Data Providers help run the same test with multiple data sets, improving test coverage and reducing code duplication.
Click to reveal answer
intermediate
Show a simple example of a Data Provider method in Java for Selenium tests.
Example:
@DataProvider(name = "loginData")
public Object[][] getData() {
return new Object[][] {
{"user1", "pass1"},
{"user2", "pass2"}
};
}
Click to reveal answer
beginner
How do you link a test method to a Data Provider in TestNG?
Use the @Test annotation with the dataProvider attribute, like @Test(dataProvider = "loginData"), to connect the test method to the Data Provider.
Click to reveal answer
What return type should a Data Provider method have in TestNG?
✗ Incorrect
A Data Provider method returns Object[][] or Iterator
Which annotation is used to mark a Data Provider method?
✗ Incorrect
The @DataProvider annotation marks a method as a source of test data.
How do you specify which Data Provider a test method should use?
✗ Incorrect
The @Test annotation's dataProvider attribute links the test to the Data Provider.
What is the main benefit of using Data Providers?
✗ Incorrect
Data Providers allow running the same test multiple times with different inputs.
Which of these is a valid Data Provider method signature?
✗ Incorrect
Data Providers must return Object[][] or Iterator
Explain how Data Providers help in parameterizing Selenium tests with TestNG.
Think about running the same test many times with different inputs.
You got /4 concepts.
Describe the steps to create and use a Data Provider in a Selenium Java test.
Focus on method creation, annotations, and linking.
You got /4 concepts.