How to test the methods, which contain System.exit() statement?

  1. a.) There is no option to test it in Junit

  2. b.) Modifying the testcase to run with SecurityManager that prevents calling System.exit, then catch the SecurityException.

  3. c.) Remove the System.Exit() line then continue the testing with that methods.

  4. d.) Test it everything as-is.


Correct Option: B

Find more quizzes: