When I call TestHelper.cleanup() to get rid of any components or windows still possibly open the junit test thread is killed - thereby preventing other tests from running. I've tracked the problem down to line 493 of TestHelper where a window close event is posted to the event queue. Since the GUI is running on a different thread from the tests I can't see why this would happen. Any ideas?
Also, by not running cleanup I have to manually dispose of windows but for some reason menus hang around in memory, so subsequent tests that run the application increase the number of menu components and cause problems in the tests.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This may be occuring because your application has a defaultCloseOperation of JFrame.CLOSE_ON_EXIT, so the JVM exits on closing it as it was the last displayable window. Perhaps you could try using JFrame.DISPOSE_ON_EXIT instead, e.g.:
public class MyTest extends JFCTestCase {
:
public void setUp() {
:
app = new TestApp(); // extends JFrame
app.setDefaultCloseOperation(JFrame.DISPOSE_ON_EXIT);
:
}
:
}
When I call TestHelper.cleanup() to get rid of any components or windows still possibly open the junit test thread is killed - thereby preventing other tests from running. I've tracked the problem down to line 493 of TestHelper where a window close event is posted to the event queue. Since the GUI is running on a different thread from the tests I can't see why this would happen. Any ideas?
Also, by not running cleanup I have to manually dispose of windows but for some reason menus hang around in memory, so subsequent tests that run the application increase the number of menu components and cause problems in the tests.
This may be occuring because your application has a defaultCloseOperation of JFrame.CLOSE_ON_EXIT, so the JVM exits on closing it as it was the last displayable window. Perhaps you could try using JFrame.DISPOSE_ON_EXIT instead, e.g.:
public class MyTest extends JFCTestCase {
:
public void setUp() {
:
app = new TestApp(); // extends JFrame
app.setDefaultCloseOperation(JFrame.DISPOSE_ON_EXIT);
:
}
:
}
For more information see:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html
...and:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation\(int)