0

Using data provider I am fetching data from excel into a class and the test class contain multiple @Test. So now I need to pass all the arguments in the data provider to all the tests instead of using required parameters in a Test. So is there any way to declare the arguments in common, to use on

import org.testng.annotations.BeforeClass;

import org.testng.annotations.DataProvider;

import org.testng.annotations.Test;

   public class TestSample extends Library {

   @BeforeClass()

    public void Setup() {

    }


    @Test(dataProvider = "dataSupplier", priority = 0)

    public void Verify_Test1(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {

        startAdminLogin(adminName, adminPassword);
        try {       

        } finally {
            adminHomePage.clickAdminLogout();
        }
    }


    @Test(dataProvider = "dataSupplier",priority = 1)

    public void Verify_Test2(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {

        startAdminLogin(adminName, adminPassword);
        try {           

        } finally {
            adminHomePage.clickAdminLogout();
        }
    }

    @Test(dataProvider = "dataSupplier",priority = 2)

    public void Verify_Test3(String adminName, String adminPassword, String emailId, String emailId1, String emailId2, String emailId3, String deviceCountry, String firstName, String lastName, String phoneNo, String productName, String productName1, String productName2, String productName3) {

        startAdminLogin(adminName, adminPassword);
        try {           

        } finally {
            adminHomePage.clickAdminLogout();
        }
    }

    @DataProvider
    public Object[][] dataSupplier() {
        List<Object[]> list2 = ExcelHelper.getDataList("adminUsers");
        List<Object[]> list3 = ExcelHelper.getDataList(“userDetails”);
        return mergeListToArray(list2, list3);
    }
}
Grasshopper
  • 8,908
  • 2
  • 17
  • 32
Raj
  • 1
  • 1
  • Create a dataobject with getters and setters, and return a 2d array of that object. Change the input parameter of test methods to the accept that DO. – Grasshopper Dec 07 '17 at 18:45
  • I had similar requirement to read data from excel and create so many tests. I used parameterized JUnit and its working perfectly. You can give it a try. – Santosh Dec 07 '17 at 18:54

0 Answers0