However, on running the test, all that happens is
that the JUnit swingui TestRunner exits. If I comment out the call to disposeWindow(), the app loads and displays fine, and the test runs and passes.
Any ideas as to what might be causing this?
Thanks,
Michael E.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am guessing that your frame instance implements a windowlistener and you are doing a 'System.exit(0);' on the windowClosed() or windowClosing() method.
Vijay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2001-12-30
Yes, it does - the original author wanted to save any changed files before exiting, so he did add a windowListener to catch windowClosing. Should I remove the System.exit(0) call, and with what should I replace it?
BTW, great work you guys have done - if I can get this problem worked out, I will have enough ammunition to convince management to use JFCUnit with all new development. Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You would probably want a new class (non GUI) in front of your current frame class (ProductApp) which does the system.exit() by listening to the window close of the frame class. Then you should delete the call to system.exit() from the current frame. That way, you would "launch" the app by calling the new class and the tests would still work without exiting.
Vijay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I personally put a variable in the class that exits called isUnitTesting. I set this variable inside my test case. In the window listener class, I put if(!isUnitTesting) System.exit(0);
System.exit(0) exits the JVM, so if you don't have this, any tests after this test would not be run. Basically System.ext(0) will kill all windows including the testrunner GUI.
Dean
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to retrofit an existing app with JFCUnit as a proof of concept to skeptical maangement. The code looks like this:
JFrame frame;
JFCTestHelper helper;
protected void setUp()
{
helper = new JFCTestHelper();
}
protected void tearDown()
{
helper.disposeWindow(frame, this);
}
public void testMenubarPresent()
{
frame = new ProductApp();
frame.show();
awtSleep(20000);
JMenuBar menuBar = frame.getJMenuBar();
assertNotNull(menuBar);
}
However, on running the test, all that happens is
that the JUnit swingui TestRunner exits. If I comment out the call to disposeWindow(), the app loads and displays fine, and the test runs and passes.
Any ideas as to what might be causing this?
Thanks,
Michael E.
I am guessing that your frame instance implements a windowlistener and you are doing a 'System.exit(0);' on the windowClosed() or windowClosing() method.
Vijay
Yes, it does - the original author wanted to save any changed files before exiting, so he did add a windowListener to catch windowClosing. Should I remove the System.exit(0) call, and with what should I replace it?
BTW, great work you guys have done - if I can get this problem worked out, I will have enough ammunition to convince management to use JFCUnit with all new development. Thanks!
You would probably want a new class (non GUI) in front of your current frame class (ProductApp) which does the system.exit() by listening to the window close of the frame class. Then you should delete the call to system.exit() from the current frame. That way, you would "launch" the app by calling the new class and the tests would still work without exiting.
Vijay
I personally put a variable in the class that exits called isUnitTesting. I set this variable inside my test case. In the window listener class, I put if(!isUnitTesting) System.exit(0);
System.exit(0) exits the JVM, so if you don't have this, any tests after this test would not be run. Basically System.ext(0) will kill all windows including the testrunner GUI.
Dean