1 package test.factory;
2 
3 import org.testng.Assert;
4 import org.testng.annotations.DataProvider;
5 import org.testng.annotations.Factory;
6 import org.testng.annotations.Test;
7 
8 @Test(groups = { "x" })
9 public class FactoryAndTestMethodTest {
10 
11   @Factory(dataProvider = "data")
ohNo(String s)12   public Object[] ohNo(String s) {
13     return makeNullArgTests(s);
14   }
15 
16   public static class NullArgsTest {
17     public final String s;
18 
NullArgsTest(String s)19     public NullArgsTest(String s) {
20       this.s = s;
21     }
22 
23     @Test
test()24     public void test() {
25       Assert.assertNotNull(s);
26     }
27   }
28 
makeNullArgTests(String s)29   private Object[] makeNullArgTests(String s) {
30     return new Object[0];
31   }
32 
33   @DataProvider(name = "data")
makeData()34   public Object[][] makeData() {
35     return new Object[][] { { "foo" } };
36   };
37 }
38