• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test;
2 
3 import org.testng.annotations.BeforeClass;
4 import org.testng.annotations.Test;
5 
6 import test.sample.BaseSampleInheritance;
7 
8 public class SampleInheritance extends BaseSampleInheritance {
9 
10   // Test dependency of configuration methods
11   @BeforeClass(groups= { "configuration0"})
configuration0()12   public void configuration0() {
13     addConfiguration("configuration0");
14 //    System.out.println("CONFIGURATION 0");
15   }
16 
17   @BeforeClass(dependsOnGroups = { "configuration1"})
configuration2()18   public void configuration2() {
19     assert m_configurations.size() == 2
20 	: "Expected size 2 found " + m_configurations.size();
21     assert "configuration0".equals(m_configurations.get(0))
22 	: "Expected configuration0 to be run";
23     assert "configuration1".equals(m_configurations.get(1))
24 	: "Expected configuration1 to be run";
25     addConfiguration("configuration2");
26   }
27 
28   @Test(dependsOnGroups = { "inheritedTestMethod"} )
inheritedMethodsWereCalledInOrder()29   public void inheritedMethodsWereCalledInOrder() {
30     assert m_invokedBaseMethod : "Didn't invoke test method in base class";
31     assert m_invokedBaseConfiguration : "Didn't invoke configuration method in base class";
32 
33   }
34 
35   @Test
configurationsWereCalledInOrder()36   public void configurationsWereCalledInOrder() {
37     assert m_configurations.size() == 3;
38     assert "configuration0".equals(m_configurations.get(0))
39 	: "Expected configuration0 to be run";
40     assert "configuration1".equals(m_configurations.get(1))
41 	: "Expected configuration1 to be run";
42     assert "configuration2".equals(m_configurations.get(2))
43 	: "Expected configuration1 to be run";
44   }
45 }
46