title: @BeforeClass and inheritance - order of execution
body: <p>I have an abstract base class, which I use as a base for my unit tests (TestNG 5.10). In this class, I initialize the whole environment for my tests, setting up database mappings, etc. This abstract class has a method with a <code>@BeforeClass</code> annotation which does the initialization.</p>
  
  <p>Next, I extend that class with specific classes in which I have <code>@Test</code> methods and also <code>@BeforeClass</code> methods. These methods do class-specific initialization of the environment (e.g. put some records into the database).</p>
  
  <p>How I can enforce a specific order of the <code>@BeforeClass</code> annotated methods? I need the ones from the abstract base class to be executed before the ones of the extending class.</p>
  
  <p>Example:</p>
  
  <pre><code>abstract class A {
      @BeforeClass
      doInitialization() {...}
  }
  
  class B extends A {
      @BeforeClass
      doSpecificInitialization() {...}
  
      @Test
      doTests() {...}
  }
  </code></pre>
  
  <p>Expected order:</p>
  
  <pre><code>A.doInitialization
  B.doSpecificInitialization
  B.doTests
  </code></pre>
  
  <p>Actual order:</p>
  
  <pre><code>B.doSpecificInitialization // &lt;- crashes, as the base init is missing
  (A.doInitialization        // &lt;---not executed
   B.doTests)                // &lt;-/
  </code></pre>