0

I have some WebdriverSelenium/TestNG/Maven/Java continuous integration tests, that I refactored (removed a huge chain of inheritances) and now I've also installed Spring DI framework.

I just cant pass the parameters to the Test method (oneUserTwoUser)

This is the dataprovider

public class AppData { 
    public static WebDriver driver;
    public static WebDriverWait wait;
    final static String FILE_PATH = "src/test/resources/250.csv";
    final static String FILE_PATH2 = "src/test/resources/places.csv";
    public static ArrayList<ArrayList<String>> array;

    public static Object[][] setUp() throws Exception {

        //prepare data

        //read data from CSV files
        array = getCSVContent(FILE_PATH, 5);
        array2 = getCSVContent(FILE_PATH2, 7);

        //pass the data to the test case
        Object[][] setUp = new Object[1][3];
        setUp[0][0] = driver;
        setUp[0][1] = wait;
        setUp[0][2] = array;    
        return setUp;
    }

This is the test class:

public class AppTest3 {

public static AppData appdata;

public static void main (String[] args) {
    BeanFactory beanfactory = new XmlBeanFactory(new FileSystemResource("spring.xml"));
    appdata = (AppData) beanfactory.getBean("data");
}

@Parameters({ "driver", "wait", "array" })
@Factory(dataProviderClass = AppData.class, dataProvider = "setUp")
@Test
public void oneUserTwoUser(WebDriver driver, WebDriverWait wait, ArrayList<ArrayList<String>> array) throws Exception {

Error

org.testng.TestNGException: 
Parameter 'driver' is required by @Test on method oneUserTwoUser but has not been marked @Optional or defined
Kaloyan Roussev
  • 14,515
  • 21
  • 98
  • 180
  • 1
    The first thing to note is that you have the wrong number of parameters. You are passing in 4 parameters instead of the 3 that you defined in `@Parameters` and in your parameter list. What happens when you correct this? – Bob Dalgleish Aug 13 '13 at 12:21
  • Im not passing 4 parameters. A fourth parameter is available for another class to use, but here Im only passing 3. (The fourth parameter is available in the object, but never called). Anyway, I removed the fourth one, and there was no change whatsoever :( – Kaloyan Roussev Aug 13 '13 at 12:39
  • @BobDalgleish it turns out you were right, later on when I removed the big problem, after implementing the accepted answer's solution, I really got an error message complaining about me passing 4 parameters. – Kaloyan Roussev Aug 13 '13 at 12:57

1 Answers1

1

As described by the documentation:

Preface your setUp() function with @DataProvider(name="standardTestData")

Then remove all other annotations except for @Test(dataProvider="standardTestData", dataProviderClass=AppData.class)

Nathan Merrill
  • 7,648
  • 5
  • 37
  • 56