1 package test.tmp; 2 3 import org.testng.annotations.DataProvider; 4 import org.testng.annotations.Factory; 5 import org.testng.annotations.Test; 6 7 @Test(sequential = true) 8 public class AA { 9 private int m_n; 10 AA()11 public AA() {} 12 AA(int n)13 public AA(int n) { 14 m_n = n; 15 } 16 log(String s)17 private void log(String s) { 18 System.out.println(" [AA(" + m_n + ") thread:" + Thread.currentThread().getId() + "] " + s); 19 } 20 21 @DataProvider dp()22 public Object[][] dp() { 23 return new Object[][] { 24 new Object[] { 42 }, 25 }; 26 } 27 28 // @BeforeClass 29 // public void bc() { 30 // log("beforeClass"); 31 // } 32 // 33 // @AfterClass 34 // public void ac() { 35 // log("afterClass"); 36 // } 37 38 @Factory create()39 public Object[] create() { 40 return new Object[] { new A(), new AA() }; 41 } 42 43 @Test aatest1()44 public void aatest1() { 45 log("aatest1"); 46 } 47 48 @Test(dependsOnMethods = "aatest1") aatest2()49 public void aatest2() { 50 log("aatest2"); 51 } 52 53 // @Test(priority = 3) atest3()54 public void atest3() { 55 } 56 getTestName()57 public String getTestName() { 58 return "This is test A"; 59 } 60 61 // @Test(groups = "mytest", dependsOnMethods = "g") 62 // public void f() { 63 // } 64 // 65 // 66 // @AfterMethod 67 // public void after() { 68 // } 69 70 } 71