Duplicate: Java: How to test methods that call System.exit()?
I am having a bit of trouble designing a unit test for a method that exits the application by calling system.exit()
. Actually, this is the constructor of a class which tests some conditions and decides to exit the application. So it is this particular eventuality that I'd like to test.
Is there a particular assert that I could use, or any other suggestions?
public MyClass(arg1, arg2, arg3){
if(argsTestingIsOK){
continue;
}else{
System.exit(0);
}
}