To test methods containing System.exit(), you can configure a custom SecurityManager that throws a SecurityException when checkExit is called. The test case can then catch this exception to verify that the exit was triggered without terminating the JVM.