title: How to group JUnit tests together
body: <p>I'm trying to create a junit Runner that will group together common tests using the <a href="http://www.junit.org/apidocs/index.html" rel="nofollow">junit API</a>:</p>
  
  <pre><code>package whatever;
  
  import org.junit.runner.Description;
  import org.junit.runner.Runner;
  import org.junit.runner.notification.Failure;
  import org.junit.runner.notification.RunNotifier;
  
  public class SomeTestRunner extends Runner {
  
      public SomeTestRunner(Class&lt;?&gt; testClass) {}
  
      @Override
      public Description getDescription() {
          return Description.EMPTY;
      }
  
      @Override
      public void run(RunNotifier notifier) {
          for (int i = 0; i &lt; 3; i++) {
              Description parent = Description.createSuiteDescription("Parent_" + i);
              for (int j = 0; j &lt; 3; j++) {
                  Description child = Description.createTestDescription(Exception.class, "Child_" + j);
                  parent.addChild(child);
                  Failure failure = new Failure(child, new Exception());
                  notifier.fireTestFailure(failure);
              }
              Failure failure = new Failure(parent, new Exception());
              notifier.fireTestFailure(failure);
          }
      }
  }
  </code></pre>
  
  <p>The problem is, when I run a test using this Runner, I can see the failures in a row, both parents and children, instead of grouped together:</p>
  
  <pre><code>Results :
  
  Tests in error: 
    Child_0(java.lang.Exception)
    Child_1(java.lang.Exception)
    Child_2(java.lang.Exception)
    Parent_0
    Child_0(java.lang.Exception)
    Child_1(java.lang.Exception)
    Child_2(java.lang.Exception)
    Parent_1
    Child_0(java.lang.Exception)
    Child_1(java.lang.Exception)
    Child_2(java.lang.Exception)
    Parent_2
  
  Tests run: 12, Failures: 0, Errors: 12, Skipped: 0
  </code></pre>
  
  <p>Also, I expected to see them grouped together when I run this test in Eclipse - but thats not the case. What am I missing? Is it even possible?</p>