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.List;
     10 
     11 public class ConfigurationGroupDataProviderSampleTest {
     12   static List<Integer> m_list = new ArrayList<>();
     13 
     14   @BeforeGroups(groups={"twice"}, value={"twice"})
     15   public void a(){
     16     ppp("BEFORE()");
     17     m_list.add(1);
     18   }
     19 
     20   @Test(groups={"twice"}, dataProvider="MyData")
     21   public void b(int a, int b) {
     22     m_list.add(2);
     23     ppp("B()"  + a + "," + b);
     24   }
     25 
     26   @AfterGroups(groups={"twice"}, value={"twice"})
     27   public void c(){
     28     m_list.add(3);
     29     ppp("AFTER()");
     30   }
     31 
     32   @DataProvider(name="MyData")
     33   public Object[][] input(){
     34     return new Object[][]{ {1,1}, {2,2}, {3,3}};
     35   }
     36 
     37   private void ppp(String string) {
     38     if (false) {
     39       System.out.println("[A] " + string);
     40     }
     41   }
     42 
     43 
     44 }
     45