1package test.configuration; 2 3import org.testng.Assert; 4import org.testng.annotations.BeforeGroups; 5import org.testng.annotations.Test; 6 7import java.util.ArrayList; 8import java.util.List; 9 10/** 11 * Simple beforeGroups test: 1 before method and 2 test method 12 * 13 * @author cbeust 14 * @date Mar 3, 2006 15 */ 16public class ConfigurationGroups1SampleTest { 17 private boolean m_before = false; 18 private boolean m_f1 = false; 19 20 @BeforeGroups("cg1-1") 21 public void before1() { 22 Assert.assertFalse(m_before); 23 Assert.assertFalse(m_f1); 24 m_before = true; 25 log("before1"); 26 } 27 28 @Test(groups = "cg1-a") 29 public void fa() { 30 log("fa"); 31 } 32 33 @Test(groups = "cg1-1") 34 public void f1() { 35 Assert.assertTrue(m_before); 36 m_f1 = true; 37 log("f1"); 38 } 39 40 private List<String> m_list = new ArrayList<>(); 41 42 @Test(dependsOnGroups = {"cg1-a", "cg1-1"}) 43 public void verify() { 44 Assert.assertTrue(m_before); 45 Assert.assertTrue(m_f1); 46 } 47 48 private void log(String s) { 49 m_list.add(s); 50 ppp(s); 51 } 52 53 private void ppp(String s) { 54 if (false) { 55 System.out.println("[ConfigurationGroups1SampleTest] " + s); 56 } 57 } 58 59} 60