0
   DataProvider(name = "sizerDefaults")
   public Object[][] getSizerDefaults() {

   } 

    @Test(dataProvider = "sizerDefaults")
    public void sizerDefaults(String... args) {

    }

Above is my DataProvider and the methods which uses a DataProvider.

Requirement is, it possible to have parameters to a DataProvider? That is, I want to use the same DataProvider for several methods, where a String value changes every time for each method, which I should be able to pass in the @Test methods wherever I am using my @DataProvider

I expect something like

   DataProvider(name = "sizerDefaults")
   public Object[][] getSizerDefaults(String a) {

   // Will be using 'String a' somewhere  here

   } 

    // Here I should be able to pass different String values In @Test methods wherever I use this dataProvider = "sizerDefaults"
    @Test(dataProvider = "sizerDefaults")
    public void sizerDefaults(String... args) {

    }

The main question is how & where i will fetch the data from DataProvider as a array like (String .. args) or (String[] args). Because i have to do something literally with the first element that is args[0]

At the same time pass my String for each @Test that uses the dataProvider

Melvin Richard
  • 403
  • 1
  • 7
  • 15
  • Possible duplicate of [Possible to pass parameters to TestNG DataProvider?](https://stackoverflow.com/questions/666477/possible-to-pass-parameters-to-testng-dataprovider) – Guy Oct 11 '18 at 06:54
  • If that is the case where how & where i will fetch the data from DataProvider as a array like (String .. args) or (String[] args). Because i have to do something literally with the first element that is args[0] – Melvin Richard Oct 11 '18 at 13:52

0 Answers0