title: TestNG: All subsequent Test classes are skipped when @BeforeClass method fails?
body: <h3>My setup:</h3>
  
  <ul>
  <li>A <strong>TestBase class</strong> containing a @BeforeClass method</li>
  <li><strong>Several Test classes</strong> extending from TestBase class and also containing a @BeforeClass method</li>
  <li>testNG 6.8.8</li>
  </ul>
  
  <h3>Why this setup?:</h3>
  
  <ul>
  <li>I need the @BeforeClass in the TestBase class to provide setup that all testclasses will need and I don't want to repeat in every Test class. For example thread-id-dependent login credentials.</li>
  <li>TestBase class also instantiates the Selenium WebDriver</li>
  <li>I need the @BeforeClass in the Test classes to initialize everything that all @Test methods will need to use but that only needs to (or must) be built/invoked once for all tests. This includes calls to said WebDriver instance (that's why a "normal" constructor doesn't work here)</li>
  </ul>
  
  <h3>Here's what happens:</h3>
  
  <p>When I run the tests via a testNG xml file and there is an <strong>exception within the @BeforeClass</strong> method of one of the Test classes, then <strong>all subsequent Test classes are skipped by TestNG</strong>.</p>
  
  <h2>Why does this happen? How to prevent it?</h2>
  
  <p>When I change the annotation in the TestBase class to <strong>@BeforeSuite</strong> for example, then <strong>all tests are run</strong>, even if there is an exception in on of the @BeforeClass methods.</p>
  
  <h3>Example:</h3>
  
  <p>When you run the xml file, complete RunAllTestClasses02 class is skipped.</p>
  
  <p><strong>testNG xml file:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;suite name = "MiscSuite"&gt;
      &lt;test name = "MiscTest"&gt;
          &lt;classes &gt;
              &lt;class name="drkthng.misc.RunAllTestClasses01" /&gt;
              &lt;class name="drkthng.misc.RunAllTestClasses02" /&gt;
          &lt;/classes&gt;
      &lt;/test&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p><strong>TestBase class with a @BeforeClass method:</strong></p>
  
  <pre><code>public abstract class RunAllTestClassesBase {
  
      @BeforeClass
      public void beforeClass() {
          // do something that all Test classes will need
      }
  }
  </code></pre>
  
  <p><strong>Test class that throws Exception within @BeforeClass method:</strong></p>
  
  <pre><code>public class RunAllTestClasses01 extends RunAllTestClassesBase {
  
      @BeforeClass
      public void beforeClass() {
          Assert.assertTrue(false);
      }
  
      @Test
      public void Test01() {
          Assert.assertTrue(true);
      }
  }
  </code></pre>