Search code examples
selenium-webdriverautomationtestngjunit4

Using only one dataprovider , how to pass data to many test methods


Im using DataProvider in TestNG for my Selenium Scripts . My requirement is to just use a single DataProvider and pass the data to many test methods .

For example : Say i have 10 test methods , So i need to create a Single DataProvider , so that it can pass data to all those 10 Test methods.

Is it possible to do it ? If yes , how to implement it .

Or is there any alternative for this ??

Pl Help !!!


Solution

  • If each of your test method has @Test annotation, then you can simply add parameter to this as -

    @Test(dataProvider="Name of your DataProvider")
    

    You can do this with all of the 10 test methods & this will make them get data from your single DataProvider.

    I hope it helps. . .cheers!!