Reputation: 465
I'm working on a GUI program written in Java (using Swing) in Eclipse. I usually develop on Windows, and I am able to run\debug the program in Eclipse and it displays just fine. (I'm using a JUnit test to run the different windows of the GUI program).
However, I recently put Ubuntu on my machine on a second partition on my hard drive, installed Eclipse, and tried to run the JUnit test, but the GUI window appears for a second then disappears. The rest of the JUnit test runs just fine, (0 errors, 0 failures) but I can't see the GUI. Anyone know why this would happen? Thanks.
Upvotes: 3
Views: 1335
Reputation: 465
Ok, I figured it out. GUIs aren't meant to be run in JUnit tests, because as soon as the tests are completed, the program will exit, and the GUI will immediately close. For some reason, the program was staying open when I ran the JUnit test in Windows, but that's not really supposed to happen.
Because, in the current project that I'm working on, it makes more sense for me to open the GUI in a JUnit test, I implemented the following workaround: I had the method that ran the GUI simply wait until the GUI is closed before it continued to execute. To do this, I used the mechanism described here.
Upvotes: 1