title: Getting list of tests from JUnit command line
body: <p>My problem, in short, is that I want to run some JUnit tests from a command line and I would like to be able to see:</p>
  
  <ul>
  <li>A list of all tests (whether they ran or not).</li>
  <li>A list of all  tests which passed.</li>
  <li>A list of all tests which failed</li>
  </ul>
  
  <p>The reason for the first bullet, is because I believe if one test calls System.exit, the others won't run, I still want to know about these tests, even if they didn't run.</p>
  
  <p>Lets say I have this test class:</p>
  
  <pre><code>    import junit.framework.TestCase;
      public class ALoadOfTests extends TestCase {
  
      public void testFoo() {
          int a = 5;
          int b = 10;
          int result = a + b;
          assertEquals(15, result);
      }
  
      public void testBar() {
          fail();
      }
  
      public void testBaz() {
          fail();
      }       
  }
  </code></pre>
  
  <p>If I run this using the commands:</p>
  
  <pre><code>javac -cp ".;C:\Users\username\Desktop\Test\junit-4.11.jar;C:\Users\username\Desktop\Test\hamcrest-core-1.3.jar" ALoadOfTests.java
  java -cp ".;C:\Users\username\Desktop\Test\junit-4.11.jar;C:\Users\username\Desktop\Test\hamcrest-core-1.3.jar" junit.textui.TestRunner ALoadOfTsts
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>.F.F.
  Time: 0.002
  There were 2 failures:
  1) testBar(ALoadOfTests)junit.framework.AssertionFailedError
          at ALoadOfTests.testBar(ALoadOfTests.java:12)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  2) testBaz(ALoadOfTests)junit.framework.AssertionFailedError
          at ALoadOfTests.testBaz(ALoadOfTests.java:16)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  
  FAILURES!!!
  Tests run: 3,  Failures: 2,  Errors: 0
  </code></pre>
  
  <p>The problem here is that the output doesn't tell me the name of testFoo which exists and passed.
  Furthermore, if I change one of them to use System.exit, then we don't get much output at all, we just get:</p>
  
  <pre><code>.F.F.
  </code></pre>
  
  <p>Ideally, to be able to get all the information I need, if I could print out a list of test names first, before any tests are ran (and any chance of System.exit) then I can see which passed and which failed (or didn't run).</p>
  
  <p>If I could get output that just looks similar to:</p>
  
  <pre><code>Tests:
  testFoo
  TestBar
  TestBaz
  Results:
  TestFoo(passed)
  TestBar(failed:reason)
  </code></pre>
  
  <p>Then I could safely assume:</p>
  
  <pre><code>TestFoo passed
  TestBar failed
  TestBaz never ran, probably because some test called system.exit.
  </code></pre>
  
  <p>Is this possible using a custom runner? If it is, any hints on where to start would be greatly appreciated.</p>
  
  <p>Unfortunately I have no control over the code, it should be assumed that it may contain System.exit, possibly, in every method. I also have little control over the tests, so printing out the test names in the setup method isn't ideal.</p>
  
  <p>Thanks,</p>