package testng;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
public class FirstTest {
@Test
public void f() {
System.out.println("foo");
}
@DataProvider(name = "Data")
public static Object[][] Data() {
return new Object[][]{{"11"},{"22"}};
}
@Test(dataProvider = "Data", priority = 1)
public void f1(String txt) {
System.out.println("f1" + txt);
}
@BeforeMethod
public void beforeMethod() {
System.out.println("@beforeMethod");
}
@AfterMethod
public void afterMethod() {
System.out.println("@afterMethod");
}
@BeforeClass
public void beforeClass() {
System.out.println("@beforeClass");
}
@AfterClass
public void afterClass() {
System.out.println("@afterClass");
}
@BeforeTest
public void beforeTest() {
System.out.println("@beforeTest");
}
@AfterTest
public void afterTest() {
System.out.println("@afterTest");
}
@BeforeSuite
public void beforeSuite() {
System.out.println("@beforeSuite");
}
@AfterSuite
public void afterSuite() {
System.out.println("@afterSuite");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
<test name="First TestNG demo">
<classes>
<class name="testng.FirstTest"/>
</classes>
</test>
</suite>