Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to stop queued JUnit tests and still keep the JavaFX Gui running?

I'm writing a program that sets up a GUI to start JUnit test scripts that utilize Selenium WebDriver in Java. The GUI sets up a queue of JUnit tests in the background (or so i believe). On the GUI, I want to utilize a "stop test" button that will stop all future JUnit tests that are still in the Queue from executing, but i want to do it in a timely manner. I currently have code that will stop all tests, but if 190 tests are in the queue, it takes upwards of 1-2 seconds to stop a singular test in the queue from executing which is not timely nor consumer friendly when you consider that many tests:

Field field = JUnitCore.class.getDeclaredField("fNotifier");
field.setAccessible(true);
RunNotifier runNotifier = (RunNotifier) field.get(runner);
runNotifier.pleaseStop();

is there a way to either clear the queue of the JUnit test or a specific thread to close that will stop the execution of scripts without killing the GUI?

like image 430
Brent Thoenen Avatar asked Jun 08 '15 20:06

Brent Thoenen


1 Answers

How are you defining your threads in your xml file? Found some stuff using the parallel variable to kill all specific threads immediately. Maybe if you name your threads with something common and increment a counter to put a "_1" ... "_2" and so on at the end of the common name, you could loop through quickly and kill the thread directly? You mentioned a queue of tests that you weren't positive on how it worked, maybe take the queue into your own hands manually and kill them all.

like image 83
Jon Sansoucie Avatar answered Sep 28 '22 06:09

Jon Sansoucie