title: In junit 4 @Beforeclass @Before and @After tests cases: wrong order of execution
body: <p>I am trying to run some simple tests using Junit 4 library and am using <code>@Before</code>, <code>@After</code>, and <code>@BeforeClass</code> annotations. But the problem is <code>@Before</code> and <code>@After</code> are being executed before the <code>@BeforeClass</code>. why is that?  </p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>import junit.runner.Version;
  import org.junit.After;
  import org.junit.Before;
  import org.junit.BeforeClass;
  import org.junit.Test;
  
  public class TestClass2
  {
      @BeforeClass
      public static void before() throws Exception
      {
          System.out.println("Before class");
      }
  
      @Before
      public void setUp() throws Exception
      {
          System.out.println("Before");
      }
  
      @After
      public void tearDown() throws Exception
      {
          System.out.println("After");
  
      }
  
      @Test
      public void name() throws Exception
      {
          System.out.println("Test");
          System.out.println("JUnit version is: " + Version.id());
      }
  }
  </code></pre>
  
  <p><strong>Output:</strong> </p>
  
  <blockquote>
  <pre><code>Before
  Test
  JUnit version is: 4.12
  After
  Before class
  
  Process finished with exit code 0
  </code></pre>
  </blockquote>