1 package test.factory;
2 
3 import org.testng.Assert;
4 import org.testng.ITestResult;
5 import org.testng.TestListenerAdapter;
6 import org.testng.TestNG;
7 import org.testng.annotations.Test;
8 
9 import test.SimpleBaseTest;
10 
11 import java.util.List;
12 
13 public class FactoryOrderMainTest extends SimpleBaseTest {
14 
15   @Test
factoriesShouldBeInvokedInTheOrderOfCreation()16   public void factoriesShouldBeInvokedInTheOrderOfCreation() {
17     TestNG tng = create(FactoryOrderTest.class);
18     TestListenerAdapter tla = new TestListenerAdapter();
19     tng.addListener(tla);
20     tng.run();
21 
22     List<ITestResult> passed = tla.getPassedTests();
23     for (int i = 0; i < passed.size(); i++) {
24       Assert.assertEquals(((FactoryOrderSampleTest) passed.get(i).getInstance()).getValue(), i);
25     }
26   }
27 }
28