A common topic in the mailing list is how to handle "System.exit." The typical example is simulating a user selecting the menus File -> Exit from a GUI test. By doing this, the application will quit and any GUI test trying to use the application will fail.
To prevent this failure and to test that in fact System.exit is being handled correctly by the application, FEST provides a NoExitSecurityManager that will prevent the application to end. To use it, simply add a call to NoExitSecurityManagerInstaller as follows:
By default, NoExitSecurityManager will just prevent the application from quitting if System.exit is called. If you want to do something when System.exit is called, do the following:
- Implement a
ExitHook - Pass an instance of your
ExitHooktoNoExitSecurityManagerInstaller.install(ExitHook)