下面是TestNG的最简单的一个例子
package firstprograme; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class NewTest { @BeforeClass //只运行一次 public void beforeClass() { System.out.println("this is before class"); } @Test public void TestNgLearn() { System.out.println("this is TestNG test case"); } @AfterClass //只运行一次 public void afterClass() { System.out.println("this is after class"); } }