1 package test.sample;
2 
3 
4 import org.testng.annotations.BeforeClass;
5 import org.testng.annotations.Test;
6 
7 import java.util.ArrayList;
8 import java.util.List;
9 
10 
11 /**
12  * @author Cedric Beust, Apr 30, 2004
13  *
14  */
15 public class BaseSampleInheritance {
16 
17   protected List<String> m_configurations = new ArrayList<>();
18 
addConfiguration(String c)19   protected void addConfiguration(String c) {
20     m_configurations.add(c);
21     }
22 
23   protected boolean m_invokedBaseMethod = false;
24 
25   @Test(groups = { "inheritedTestMethod" })
baseMethod()26   public void baseMethod() {
27     m_invokedBaseMethod = true;
28   }
29 
30   protected boolean m_invokedBaseConfiguration = false;
31 
32   @BeforeClass
baseConfiguration()33   public void baseConfiguration() {
34     m_invokedBaseConfiguration = true;
35   }
36 
37   @BeforeClass(groups = { "configuration1" },
38                  dependsOnGroups = { "configuration0" })
configuration1()39   public void configuration1() {
40 //    System.out.println("CONFIGURATION 1");
41     addConfiguration("configuration1");
42   }
43 
44   @Test(dependsOnGroups = { "inheritedTestMethod" })
testBooleans()45   public void testBooleans() {
46     assert m_invokedBaseMethod : "Didn't invoke test method in base class";
47     assert m_invokedBaseConfiguration : "Didn't invoke configuration method in base class";
48   }
49 
50 }
51