I created a testdata in with .
Ex:

#UserName#      #Password#     #PhoneNumber#
invalidUsername validPassword    validPhoneNumber
vaidUsername    invalidPassword  vaildPhoneNumber
vaildUsername   vaildPassword    invailidPhonenumber

When I perform the tests, Each test case will show an error message according the error. Ex:

"Please enter valid username" 
"Please enter correct password" 
"please enter correct phone number"

I’m using framework. I want to use the @ method and @test to execute my tests. Is it possible to use one for multiple test cases?

Example test I wanted to perform is follow

        @Test(priority=1, dataProvider="getFormTestData")
        public void invalidUsername(String firstName, String lastName, String phoneNumber) {
        System.out.println("Please enter valid username");
        }     

       @Test(priority=2, dataProvider="getFormTestData")
        public void invalidPassword(String firstName, String lastName, String phoneNumber) {
        System.out.println("Please enter valid Password");
        }    

       @Test(priority=3, dataProvider="getFormTestData")
        public void invalidPhoneNumber(String firstName, String lastName, String phoneNumber) {
        System.out.println("Please enter valid Phone Number");
        }    

I’m reading the excel file by each row and column.

        public Object[][] getFormTestData(){
        Object data[][] = UtilPage.getTestData(sName);
        return data;
    }



Source link https://sqa.stackexchange.com/questions/32010/how-to-test-using-one-excel-dataprovider-in-testng-for-multiple-test-cases

LEAVE A REPLY

Please enter your comment!
Please enter your name here