1 package test.dataprovider; 2 3 import org.testng.Assert; 4 import org.testng.annotations.DataProvider; 5 import org.testng.annotations.Test; 6 7 public class Sample1Test { 8 private boolean m_ok1 = false; 9 private boolean m_ok2 = false; 10 11 private static final String FN2 = "Anne Marie"; 12 private static final Integer LN2 = 37; 13 private static final String FN1 = "Cedric"; 14 private static final Integer LN1 = 36; 15 16 @DataProvider(name = "test1") createData()17 public Object[][] createData() { 18 return new Object[][] { 19 new Object[] { FN1, LN1 }, 20 new Object[] { FN2, LN2 }, 21 }; 22 } 23 24 @Test(dataProvider = "test1") verifyNames(String firstName, Integer age)25 public void verifyNames(String firstName, Integer age) { 26 if (firstName.equals(FN1) && age.equals(LN1)) { 27 m_ok1 = true; 28 } 29 if (firstName.equals(FN2) && age.equals(LN2)) { 30 m_ok2 = true; 31 } 32 } 33 34 @Test(dependsOnMethods = {"verifyNames"}) verifyCount()35 public void verifyCount() { 36 Assert.assertTrue(m_ok1 && m_ok2); 37 } 38 } 39