Home | History | Annotate | Download | only in configuration
      1 package test.configuration;
      2 
      3 import org.testng.Assert;
      4 import org.testng.annotations.AfterGroups;
      5 import org.testng.annotations.BeforeGroups;
      6 import org.testng.annotations.Test;
      7 
      8 import java.util.ArrayList;
      9 import java.util.Arrays;
     10 import java.util.List;
     11 
     12 public class ConfigurationGroups7SampleTest {
     13   private List<String> m_log = new ArrayList<>();
     14 
     15    @BeforeGroups({"A"})
     16    private void initA() {
     17      m_log.add("1");
     18    }
     19 
     20    @Test(groups = {"A"})
     21    public void testSomething() {
     22      m_log.add("2");
     23    }
     24 
     25    @Test(groups = {"A"})
     26    public void testSomethingMore() {
     27      m_log.add("2");
     28    }
     29 
     30    @AfterGroups({"A"})
     31    private void cleanUpA() {
     32      m_log.add("3");
     33    }
     34 
     35    @Test(dependsOnGroups = "A")
     36    public void verify() {
     37      Assert.assertEquals(Arrays.asList(new String[] { "1", "2", "2", "3"}), m_log);
     38    }
     39 
     40 }
     41