1 package test.dataprovider; 2 3 import org.testng.Assert; 4 5 import java.util.Iterator; 6 7 public class IterableTest { 8 private boolean m_ok1 = false; 9 private boolean m_ok2 = false; 10 11 public static final String FN2 = "Anne Marie"; 12 public static final Integer LN2 = 37; 13 public static final String FN1 = "Cedric"; 14 public static final Integer LN1 = 36; 15 16 public static final Object[][] DATA = new Object[][] { 17 new Object[] { FN1, LN1 }, 18 new Object[] { FN2, LN2 }, 19 }; 20 21 /** 22 * @testng.data-provider name="test1" 23 */ 24 public Iterator createData() { 25 return new MyIterator(DATA); 26 } 27 28 /** 29 * @testng.test dataProvider="test1" 30 */ 31 public void verifyNames(String firstName, Integer age) { 32 if (firstName.equals(FN1) && age.equals(LN1)) { 33 m_ok1 = true; 34 Assert.assertEquals(MyIterator.getCount(), 1); 35 } 36 if (firstName.equals(FN2) && age.equals(LN2)) { 37 m_ok2 = true; 38 Assert.assertEquals(MyIterator.getCount(), 2); 39 } 40 } 41 42 /** 43 * @testng.test dependsOnMethods = "verifyNames" 44 */ 45 public void verifyCount() { 46 Assert.assertTrue(m_ok1 && m_ok2); 47 } 48 49 private static void ppp(String s) { 50 System.out.println("[IterableTest] " + s); 51 } 52 } 53 54 55