title: JUnit Enclosed runner and shared setup
body: <p>I'm experimenting with the JUnit <code>Enclosed</code> runner in order to try and improve the organisation of some of my tests. At the moment I'm trying to work out how to share some setup between the inner classes. </p>
  
  <p>Attempt the first:</p>
  
  <pre><code>@RunWith(Enclosed.class)
  public class EnclosedTest {
  
      @Before
      public void printSomething() {
          System.out.println("Helllooo Meggan");
      }
  
      public static class FirstTest {
  
          @Test
          public void assertThatSomethingIsTrue() {
              assertThat(true, is(true));
          }
      }
  
      public static class SecondTest {
  
          @Test
          public void assertThatSomethingIsFalse() {
              assertThat(false, is(false));
          }
      }
  }
  </code></pre>
  
  <p>Unfortunately, no-one says hello to Meggan.  If I update an inner class to extend the outer one, then I get the following:</p>
  
  <pre><code>java.lang.Exception: class 'org.scratch.EnclosedTest$FirstTest' (possibly indirectly) contains itself as a SuiteClass
  at org.junit.runners.model.InitializationError.&lt;init&gt;(InitializationError.java:32)
  </code></pre>
  
  <p>Is there a particular <code>Enclosed</code> idiom to use when trying to share setup between inner test classes? I was hoping it would be as simple as the <a href="http://zendeveloper.blogspot.co.uk/2012/01/structuring-unit-tests.html" rel="noreferrer">C# example I found</a>.</p>