title: How to instantiate a shared resource in JUnit
body: <p>I noticed that jUnit runs the constructor of my test class for each method being tested.  Here's an example:</p>
  
  <pre><code>
  public class TestTest {
      protected BigUglyResource bur;
      public TestTest(){
          bur=new BigUglyResource();
          System.out.println("TestTest()");
      }
      @Test
      public void test1(){
          System.out.printf("test1()\n");
      }
  
      @Test
      public void test2(){
          System.out.printf("test2()\n");
      }
      @Test
      public void test3(){
          System.out.printf("test3()\n");
      }
  }
  </code></pre>
  
  <p>Gives the following result:</p>
  
  <pre>
  TestTest()
  test1()
  TestTest()
  test2()
  TestTest()
  test3()
  </pre>
  
  <p>Calling the constructor to BigUglyResource is too time-consuming,  I'd prefer to build it only once.  I know you can use @BeforeClass to run a method once, but @BeforeClass is only for static methods.  Static methods can't access a class property like BigUglyResource in the example above.  Other than building a Singleton, what options are there?</p>