This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I'm using JUnit 4. I'm testing a class that throws System.exit(-1) if something goes wrong (I need this because I'm invoking the task through Ant). How do I use JUnit to detect if a System.exit(-1) has been invoked?
Thanks, - Dave
ps - Please don't post any answers saying I need to change my Java code unless your solution is also compatible with the way Ant recognizing how targets succeed and fail.
It sounds like you are using the System.exit() to differentiate a test failure/error from some sort of horrible system failure. I don't follow how this would work though because the System.exit() would kill the JUnit test calling the code that has the horrible failure. I would say to mock out the System.exit call, but I think I am misunderstanding your scenario.
Or maybe you are testing an Ant task via JUnit. In which case, why not have the task throw a BuildException rather than System.exit?