assertj / assertj-swing

Fluent assertions for Swing apps
Other
107 stars 52 forks source link

Add support for aborting all running FEST Swing tests #82

Open croesch opened 10 years ago

croesch commented 10 years ago

Issue by Peter Murray from Tue, 16 Nov 2010 10:12:03 -0600 Originally opened as http://jira.codehaus.org/browse/FEST-405


There is currently no way to terminate all the running FEST Swing tests once they have been invoked via JUnit (and maybe TestNG). The existing EmergencyAbortListener will only terminate the currently running test, which is of no great use when invoking a masive suite of tests from a build tool like Maven, or you are executing a JUnit TestSuite.


votes (original issue): 0 watches (original issue): 0

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:14:49 -0600


Attachment AbortListener.java (size=398)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:14:49 -0600


Attachment BasicTestTerminator.java (size=943)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:14:49 -0600


Attachment EmergencyAbortListener.java (size=5843)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:17:53 -0600


Attachment GUITestRunner.java (size=4571)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:17:00 -0600


Attachment TestTerminator.java (size=2362)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:17:00 -0600


Attachment UserInvokedAbortException.java (size=517)

croesch commented 10 years ago

Comment by plm31 from Tue, 16 Nov 2010 10:30:25 -0600


I have attached the modified source files that can provide a solution to this problem when running under JUnit 4.5+.
It was necessary to use a static "user aborted" flag in the GUITestRunner to ensure that the tests when running as a suite (or via the maven-surefire-plugin) to all be aborted. The use of the static flag allows for tests to be terminated provided that they share the same JVM. This means that for the maven-surefire-plugin, fork modes of never and once are supported but, a fork mode of always is not as a new JVM is created for each test. I cannot see that being much of a problem for GUI tests in general, but if it is then, some kind of "abort file" on disk would be a possible solution as this would exist outside of the JVM. I played with that idea at first, but it was more hassel than it was worth as I was not interested in the always fork mode when running tests and it became difficult to "clean up" after an abort was triggered.

The attached files preserve the current behaviour added with the EmergencyAbortListener, but also add in the necessary hooks to modify the abort behaviour so that suites can be aborted when using a GUITestRunner. If you were to break backwards compatibility, then the supplied code could be tidied up a little more.

The GUITestRunner also has an annotation @GuiTestRunner.AbortKeyPress that allows for developers to specify a custom key press to abort the running tests, which will most likely be necessary as the default CTRL+SHIFT+A is a common shortcut for select all in our code.

jasonwest08 commented 8 years ago

Is there a solution that works for TestNG?

croesch commented 8 years ago

As this issue is open there should be neither a solution for JUnit nor for TestNG.

Unfortunately the attached patches are unavailable as codehaus is not available anymore. So one has to check an internet archive for getting the patches. Then the solution for TestNG should be straight forward..