import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class NGTest1 {
@BeforeTest()
public void loadFile() {
System.out.println("File open....");
}
@BeforeMethod
public void openBrowser() {
System.out.println("Browser opened************");
}
@AfterMethod
public void closeBrowser() {
System.out.println("**************Close browser");
}
@DataProvider(name = "Numbers")
public static Object[][] getMumbers() {
return new Object[][] { { 1, 2,3}, { 4, 5,6 } };
}
@Test(priority = 1, dataProvider = "Numbers")
public void add(int number1, int number2,int number3) {
System.out.println(number1);
System.out.println(number2);
System.out.println(number3);
System.out.println("Total "+ number1+number2+number3);
}
@Test(priority = 2)
public void substract() {
System.out.println("Substraction");
}
@Test(priority = 3)
public void Multiply() {
System.out.println("Multiply");
}
@Test(priority = 4)
public void Divide() {
System.out.println("Divide");
}
@AfterTest
public void closeFile() {
System.out.println("File closed.....");
}
}
Sunday, February 17, 2019
@Data Provider and other Annotations of TestNG
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment