1 package test.factory.classconf; 2 3 import org.testng.annotations.AfterClass; 4 import org.testng.annotations.BeforeClass; 5 import org.testng.annotations.Factory; 6 import org.testng.annotations.Test; 7 8 9 /** 10 * This class/interface 11 */ 12 public class XClassOrderWithFactory { 13 public static final String EXPECTED_LOG= "BTABTABTA"; 14 public static final StringBuffer LOG= new StringBuffer(); 15 16 @Factory createInstances()17 public Object[] createInstances() throws Exception { 18 return new Object[] { 19 new XClassOrderTest(), new XClassOrderTest(), new XClassOrderTest() 20 }; 21 } 22 23 public static class XClassOrderTest { 24 @BeforeClass beforeClass()25 public void beforeClass() { 26 LOG.append("B"); 27 } 28 test()29 public @Test void test() { 30 LOG.append("T"); 31 } 32 afterClass()33 public @AfterClass void afterClass() { 34 LOG.append("A"); 35 } 36 } 37 } 38