title: Executing global teardown method after last test in junit4
body: <p>I would like to know if there is a way to execute some method after executing my tests.
  I am using eclipse and i would like to be able to run some or all of my tests and then execute some code,
  so that junit will always execute my tear down once, always after the last test.</p>
  
  <p>The concrete problem is that I am using selenium webdriver and i would like to execute webdriver's quit method after all my tests are done. First I had static class managing webdriver reference, now i moved to singleton pattern. I believe there could be better solution, but right now I don't want to use any IoC containers since I am java beginner.</p>
  
  <p>So far i tried few approaches but none was successful.</p>
  
  <p>Suit approach only works when i execute all my test:</p>
  
  <pre><code>@RunWith(Suite.class)
  @SuiteClasses({SomeTest.class, OtherTest.class, AnotherTest.class})
      public class TestSuit {
  
      @BeforeClass
      public static void setUp() {
          System.out.println("setting up");
      }
  
      @AfterClass
      public static void tearDown() {
          System.out.println("tearing down");
      }
  }
  </code></pre>
  
  <p>but what if i would like to run just one test class or all tests from one specific namespace?</p>
  
  <p>After class approach works only if all my test are grouped in one class.</p>
  
  <p>I believe that NUnit has implemented <a href="http://www.nunit.org/index.php?p=setupFixture&amp;r=2.5.10" rel="nofollow">SetUpFixtureAttribute</a> , which is doing what i would like to gain, is there any counterpart in jUnit? </p>