01: package test.factory;
02:
03: import org.testng.Assert;
04:
05: public class FactoryTest {
06:
07: static boolean m_invoked = false;
08:
09: /**
10: * @testng.before-suite
11: */
12: public void init() {
13: m_invoked = false;
14: }
15:
16: /**
17: * @testng.parameters value = "factory-param"
18: * @testng.factory
19: */
20: public Object[] createObjects(String param) {
21: assert "FactoryParam".equals(param) : "Incorrect param: "
22: + param;
23:
24: Assert.assertFalse(m_invoked, "Should only be invoked once");
25: m_invoked = true;
26:
27: return new Object[] { new FactoryTest2(42),
28: new FactoryTest2(43) };
29: }
30:
31: }
|