1

I use Jemmy for Java GUI testing. Is it possible to test closing application?

Currently I simulate a click on the exit button (causing System.exit(0)) and the test fails:

junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)

Thanks, Andrey

Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
anagaf
  • 2,120
  • 1
  • 18
  • 15
  • possible duplicate of [Dealing with System.exit(0) in JUnit tests](http://stackoverflow.com/questions/6141252/dealing-with-system-exit0-in-junit-tests) – Pops Nov 16 '11 at 23:11
  • You might want to try the SecurityManager approach described in the answer to [this question](http://stackoverflow.com/questions/6141252/dealing-with-system-exit0-in-junit-tests). – bkimminich Sep 23 '11 at 06:56

2 Answers2

0

You could potentially override security manager and check that System.exit() is going to happen.

Java: How to test methods that call System.exit()?

Community
  • 1
  • 1
Shura
  • 175
  • 8
0

You could try to do it with an Action from the File menu and Exit.

        Action action = new Action("File|Exit", null);
        action.perform();