Due to the fact that you need a GUI and a user interface during the execution of the test, this is a "functional" test, not a "unit" test.
You can write the results to a file at the end, this will have an additional advantage, which could be argued that the result is correct / present at the end. If you really want the test to run, you can insert an endless loop at the end of the test:
JUnit 3:
public void tearDown() { while (true) { Thread.sleep(2000); }; }
JUnit 4:
@After public void tearDown() { while (true) { Thread.sleep(2000); }; }
This will cause the JUnit thread to start, but you will need to make sure that your GUI events are being processed in another thread.
source share