title: Java: How to test methods that call System.exit()?
body: <p>I've got a few methods that should call <code>System.exit()</code> on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since <code>System.exit()</code> terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I subsitute a stub for <code>System.exit()</code>? </p>
  
  <p>[EDIT] The class in question is actually a command-line tool which I'm attempting to test inside JUnit. Maybe JUnit is simply not the right tool for the job? Suggestions for complementary regression testing tools are welcome (preferably something that integrates well with JUnit and EclEmma).</p>