How to test methods that call System.exit()?

Indeed, Derkeiler.com suggests: Why System.exit() ? Instead of terminating with System.exit(whateverValue), why not throw an unchecked exception? In normal use it will drift all the way out to the JVM’s last-ditch catcher and shut your script down (unless you decide to catch it somewhere along the way, which might be useful someday). In the JUnit … Read more

Java: How to test methods that call System.exit()?

Indeed, Derkeiler.com suggests: Why System.exit() ? Instead of terminating with System.exit(whateverValue), why not throw an unchecked exception? In normal use it will drift all the way out to the JVM’s last-ditch catcher and shut your script down (unless you decide to catch it somewhere along the way, which might be useful someday). In the JUnit … Read more