Anisha
Anisha

Reputation: 1

Data Provider annotation of Testing

I'm new to Selenium... Can anyone please explain me Data Provider annotation of Testing in easy way with examples.

P.S.: I have searched in your site for this topic but I didn't get the basic leveler explanation

Your help is much appreciated.

Upvotes: 0

Views: 238

Answers (2)

user6161210
user6161210

Reputation:

hi to understand data provider read below

Marks a method as supplying data for a test method. The annotated method must return 
an Object[][] where each Object[] can be assigned the parameter list of 
the test method.The @Test method that wants to receive data from this DataProvider needs 
to use a dataProvider name equals to the name of this annotation.

for more info go to official url http://testng.org/doc/documentation-main.html

Upvotes: 1

djangofan
djangofan

Reputation: 29689

The @DataProvider annotation is a TestNG feature, not Selenium. The data provider allows you to pass an entire row of test data, from a spreadsheet, directly into your test method, OR you can pass a instance of webdriver (generated inside the dataprovider method, complete with desired Selenium capabilities) directly into each method under test. Also, in @Before annotations, you can access things coming from data provider and make setup decisions before your test starts. For, example, your if CSV row data contains a particular environment name, you can call a environment test fixture based on that value, before the test starts.

The HOW of how it works, is partially explained in the above link.

Upvotes: 0

Related Questions