1 package test.dependent; 2 3 import org.testng.annotations.DataProvider; 4 import org.testng.annotations.Factory; 5 import org.testng.annotations.Test; 6 import org.testng.collections.Lists; 7 8 import java.util.List; 9 10 public class GroupByInstancesSampleTest { 11 private String m_country; 12 public static List<String> m_log = Lists.newArrayList(); 13 log(String method, String country)14 private static void log(String method, String country) { 15 // System.out.println("LOG:" + method + "#" + country + " " + Thread.currentThread().getId()); 16 m_log.add(method + "#" + country); 17 } 18 19 @DataProvider dp()20 public Object[][] dp() { 21 return new Object[][] { 22 new Object[] { "usa" }, 23 new Object[] { "uk" }, 24 }; 25 } 26 27 @Factory(dataProvider = "dp") GroupByInstancesSampleTest(String country)28 public GroupByInstancesSampleTest(String country) { 29 m_country = country; 30 } 31 32 @Test signIn()33 public void signIn() { 34 log("signIn", m_country); 35 } 36 37 @Test(dependsOnMethods = "signIn") signOut()38 public void signOut() { 39 log("signOut", m_country); 40 } 41 42 @Override toString()43 public String toString() { 44 return "[GroupByInstancesSampleTest: " + m_country + "]"; 45 } 46 } 47