Home | History | Annotate | Download | only in factory
      1 package test.factory;
      2 
      3 import static org.testng.Assert.assertFalse;
      4 
      5 import org.testng.Assert;
      6 import org.testng.annotations.AfterSuite;
      7 import org.testng.annotations.Factory;
      8 import org.testng.annotations.Parameters;
      9 
     10 public class FactoryTest {
     11   static boolean m_invoked = false;
     12 
     13   @Parameters({ "factory-param" })
     14   @Factory
     15   public Object[] createObjects(String param) {
     16     Assert.assertEquals(param, "FactoryParam");
     17     assertFalse(m_invoked, "Should only be invoked once");
     18     m_invoked = true;
     19 
     20     return new Object[] {
     21         new FactoryTest2(42),
     22         new FactoryTest2(43)
     23     };
     24   }
     25 
     26   @AfterSuite
     27   public void afterSuite() {
     28     m_invoked = false;
     29   }
     30 }