-1

For Example i have one TestSuite with multiple classes.

Iteration 1 TestSuite execute in the first time it will take data in the first row of the Excel Sheet.

Iteration 2 TestSuite again execute in the second time it will take data in the second row of the Excel Sheet.

So on...

For your information -> I am using Apache POI for Data Driven. -> I am not interested to give parameter for iterate in the testng xml file itself. -> Test Suite should execute one by one.

Any help appreciated.

  • For ex: String testData = DataRead("SheetName","ColumnName"); this method calls to user defined function of read data from Excel Sheet by using Apache Poi, I can use "testData" variable any where in my classes or tests. I m just curious to iterate the test suite. Clearly says, After completion of \@AfterSuite [Close the thread] i need to invoke the \@BeforeSuite [in New Thread]. – Padmanaban Oct 04 '13 at 04:55
  • Please add this to the question instead of posting in the comments. It makes it easier for future readers to understand. – Seanny123 Oct 04 '13 at 06:07

1 Answers1

1

I guess you are using Apache POI directly from your @Test method. If yes, I'd recommend to add a DataProvider for your test and make it return an array of arrays of Excel fields, or just array of Excel lines. Please take a look at http://testng.org/doc/documentation-main.html#parameters-dataproviders, this way doesn't require specifying parameters in testng.xml.

//This method will provide data to any test method that declares that its Data Provider
//is named "dataFromExcelSheet"
@DataProvider(name = "dataFromExcelSheet")
public Object[][] createData1() {
    //I have no idea about Apache POI methods, so names are nearly random
    int numberOfRows = sheet.getNumberOfRows();
    Object[][] lines = new ExcelRow[numberOfRows][1];
    for (int i = 0; i < numberOfRows; i++) {
        lines[i][0] = sheet.getNextRow;
    }
    return lines;
}

//This test method declares that its data should be supplied by the Data Provider
//named "dataFromExcelSheet"
@Test(dataProvider = "dataFromExcelSheet")
public void yourTest(ExcelRow row) {
    //Write your code here
}
mgtriffid
  • 91
  • 1
  • 4
  • Thanks for your Solution. But the thing here is, For ex: String testData = DataRead("SheetName","ColumnName"); this method calls to user defined function of read data from Excel Sheet by using Apache Poi, I can use "testData" variable any where in my classes or tests. I m just curious to iterate the test suite. Clearly says, After completion of \@AfterSuite [Close the thread] i need to invoke the \@BeforeSuite [in New Thread]. – Padmanaban Oct 04 '13 at 04:48