public class EmergencyAbortListener extends Object implements AWTEventListener
An escape valve for users to abort a running AssertJ-Swing test by pressing 'Ctrl + Shift + A'. The key combination
to use to abort test is configurable through the method keyCombination(KeyPressInfo)
.
The following example shows to use this listener in a TestNG test:
private EmergencyAbortListener listener; @BeforeMethod public void setUp() { // set up your test fixture. listener = EmergencyAbortListener.registerInToolkit(); } @AfterMethod public void tearDown() { // clean up resources. listener.unregister(); }
Changing the default key combination for aborting test:
listener = EmergencyAbortListener.registerInToolkit().keyCombination
(key(VK_C).modifiers(SHIFT_MASK));
Modifier and Type | Method and Description |
---|---|
void |
eventDispatched(AWTEvent event)
Inspects key events for the key combination that should terminate any running AssertJ-Swing tests.
|
EmergencyAbortListener |
keyCombination(KeyPressInfo keyPressInfo)
Sets the key combination that will terminate any AssertJ-Swing test.
|
static EmergencyAbortListener |
registerInToolkit()
Attaches a new instance of
EmergencyAbortListener to the given AWT Toolkit . |
void |
unregister()
Removes this listener from the
Toolkit this listener is attached to. |
public static EmergencyAbortListener registerInToolkit()
EmergencyAbortListener
to the given AWT Toolkit
. Any other instances of
EmergencyAbortListener
will be removed from the Toolkit
.public EmergencyAbortListener keyCombination(@Nonnull KeyPressInfo keyPressInfo)
keyPressInfo
- contains information about the key code and modifiers.NullPointerException
- if the KeyPressInfo
is null
.public void unregister()
Toolkit
this listener is attached to.public void eventDispatched(AWTEvent event)
eventDispatched
in interface AWTEventListener
event
- the event to inspect.AWTEventListener.eventDispatched(java.awt.AWTEvent)
Copyright © 2014–2019 AssertJ. All rights reserved.