Home | History | Annotate | Download | only in configuration
      1 package test.configuration;
      2 
      3 import org.testng.annotations.AfterGroups;
      4 import org.testng.annotations.BeforeGroups;
      5 import org.testng.annotations.DataProvider;
      6 import org.testng.annotations.Test;
      7 
      8 import java.util.ArrayList;
      9 import java.util.Collections;
     10 import java.util.List;
     11 
     12 public class ConfigurationGroupBothSampleTest {
     13   static List<Integer> m_list = Collections.synchronizedList(new ArrayList<Integer>());
     14 
     15   private synchronized static void addToList(Integer n) {
     16     m_list.add(n);
     17   }
     18 
     19   @BeforeGroups(groups={"twice"}, value={"twice"})
     20   public void a(){
     21     ppp("BEFORE()");
     22     addToList(1);
     23   }
     24 
     25   @Test(groups={"twice"}, dataProvider="MyData", invocationCount = 2, threadPoolSize=2)
     26   public void b(int a, int b) {
     27     addToList(2);
     28     ppp("B()"  + a + "," + b);
     29   }
     30 
     31   @AfterGroups(groups={"twice"}, value={"twice"})
     32   public void c(){
     33     addToList(3);
     34     ppp("AFTER()");
     35   }
     36 
     37   @DataProvider(name="MyData")
     38   public Object[][] input(){
     39     return new Object[][]{ {1,1}, {2,2}, {3,3}};
     40   }
     41 
     42   private void ppp(String string) {
     43     if (false) {
     44       System.out.println("[A] " + string + " on Thread:" + Thread.currentThread());
     45     }
     46   }
     47 
     48 
     49 }
     50