Created
November 21, 2016 13:38
-
-
Save santhoshv339/a29d4f446a41f4d11a028d01a382ae53 to your computer and use it in GitHub Desktop.
Using Factory and Data provider with Test NG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.demo.test; | |
import org.testng.annotations.DataProvider; | |
import org.testng.annotations.Factory; | |
import org.testng.annotations.Test; | |
public class FactoryAndDataProvider { | |
private String Source; | |
private String Desination; | |
@Factory(dataProvider = "SearchProvider") | |
public FactoryAndDataProvider(String source,String destination) | |
{ | |
this.Source = source; | |
this.Desination = destination; | |
} | |
@Test(priority =1) | |
public void runTest() | |
{ | |
System.out.println(Source); | |
System.out.println(Desination); | |
} | |
@Test(priority =2) | |
public void runTest2() | |
{ | |
System.out.println(Source); | |
} | |
@DataProvider(name="SearchProvider") | |
public static Object[][] getDataFromDataprovider() { | |
return new Object[][] { {"Chennai", "Bangalore"}, {"Chennai", "Hyderabad"} }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment