title: Junit Share External Resource Between Suite Classes
body: <p>How can I share an <code>ExternalResource</code> between two classes in a junit test suite?</p>
  
  <p><strong>TestSuite.java</strong></p>
  
  <pre><code>@RunWith(Suite.class)
  @SuiteClasses({ TestA.class, TestB.class })
  public class TestSuite {
      @ClassRule
      public static MyResource res = new MyResource();
  }
  </code></pre>
  
  <p><code>MyResource</code> is an <code>ExternalResource</code> and I want to access <code>res</code> in the test suite classes TestA and TestB.</p>
  
  <p><strong>TestA.java</strong></p>
  
  <pre><code>public class TestA {
      @Test
      public void testA() {
          System.out.println("####### testA");
          // res.someGetMethod();
      }
  }
  </code></pre>
  
  <p><strong>TestB.java</strong></p>
  
  <pre><code>public class TestB {
      @Test
      public void testB() {
          System.out.println("####### testB");
          // res.someGetMethod();
      }
  }
  </code></pre>
  
  <p>Thanks for looking.</p>