2

I've got a SWT application (not Eclipse RCP based) and I currently test it using SWTBot. This works fine while running the tests from Eclipse. I'm using ant as buildsystem.

On Jenkins the tests fail - an exception is thrown

[junit] Testcase: testPasswordChange(de.rssit.kgepc.swtbot.ChangePasswordTest): Caused an ERROR
    [junit] null
    [junit] java.lang.ExceptionInInitializerError
    [junit]     at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacter(Keyboard.java:100)
    [junit]     at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Keyboard.java:89)
    [junit]     at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:92)
    [junit]     at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:78)
    [junit]     at de.foo.swtbot.pages.PasswordDialogPage.setText(PasswordDialogPage.java:70)
    [junit]     at de.foo.swtbot.pages.PasswordDialogPage.setOldPassword(PasswordDialogPage.java:30)
    [junit]     at de.foo.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:43)
    [junit]     at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getKeyboardLayout(KeyboardLayout.java:89)
    [junit]     at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:75)
    [junit]     at org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.<clinit>(Keystrokes.java:110)

Searching for this specific problem did not result in any helpful solution.

Edit:

Adding the jvm args to set US english fixes this isse and makes some tests run; all other bring the following stacktrace:

[junit] Running foo.bar.swtbot.ChangePasswordTest
[junit] Testsuite: foo.bar.swtbot.ChangePasswordTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit] 
[junit] Testcase: testPasswordChange(foo.bar.swtbot.ChangePasswordTest):    FAILED
[junit] null
[junit] junit.framework.AssertionFailedError: null
[junit]     at foo.bar.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:46)
[junit] 
[junit] 
[junit] Cobertura: Loaded information on 219 classes.
[junit] Cobertura: Saved information on 219 classes.
[junit] Test foo.bar.swtbot.ChangePasswordTest FAILED
[junit] Running foo.bar.swtbot.LoginDialogTest
[junit] Testsuite: foo.bar.swtbot.LoginDialogTest
[junit] Exception in thread "UIThread" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit]     at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
[junit]     at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
[junit]     at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
[junit]     at foo.bar.swtbot.UIThread$1.run(UIThread.java:79)
[junit]     at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
[junit]     at foo.bar.swtbot.UIThread.startEventLoop(UIThread.java:74)
[junit]     at foo.bar.swtbot.UIThread.run(UIThread.java:59)
[junit] Caused by: org.eclipse.swt.SWTException: Widget is disposed
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit]     at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit]     at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
[junit]     at org.eclipse.swt.widgets.Control.setVisible(Control.java:3725)
[junit]     at foo.bar.gui.Main.tryLogin(Main.java:142)
[junit]     at foo.bar.gui.Main.open(Main.java:117)
[junit]     at foo.bar.swtbot.AbstractMainTest$1.run(AbstractMainTest.java:46)
[junit]     at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
[junit]     at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
[junit]     ... 6 more
[junit] Exception in thread "Timer-0" org.eclipse.swt.SWTException: Widget is disposed
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit]     at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit]     at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit]     at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:582)
[junit]     at foo.bar.gui.AbstractKGEAdminDialog$1.run(AbstractKGEAdminDialog.java:46)
[junit]     at java.util.TimerThread.mainLoop(Timer.java:512)
[junit]     at java.util.TimerThread.run(Timer.java:462)
tuergeist
  • 9,171
  • 3
  • 37
  • 58
  • What OS are you running Eclipse on? What OS is the Jenkins job running on? Is the Jenkins build machine running headless? Is there more to that stacktrace? – Christopher Orr Sep 27 '11 at 15:28
  • Eclipse-OS: WinXP; Jenkins-Slave-OS: WinXP; (Jenkins Master@linux) – tuergeist Sep 29 '11 at 14:00
  • Jenkins is running as service (headless) No more stackstraces on this issue, which is fixed with the answer of sudocode. The new issue can be seen in the edited version of the question – tuergeist Sep 29 '11 at 14:01

1 Answers1

0

Regarding java.lang.ExceptionInInitializerError

I notice that there are / have been Eclipse bugs relating to missing keyboard layout for DE_DE locale. Could I suggest you check the locale settings of the process running the junit tests. If you set the locale to en_US, does the problem still arise?

Apart from setting the locale for the server process (e.g. LC_ALL environment variable?), perhaps you could use explicit locale in your junit task, e.g.

<junit fork="yes">
  <jvmarg value="-Duser.language=en"/>
  <jvmarg value="-Duser.region=US"/>

Regarding org.eclipse.swt.SWTException: Widget is disposed

Maybe this is exposing a real bug in your UI code, but I suspect you need to look at your unit tests. Are they stateless, or do they depend on a certain execution order to work reliably? Perhaps this error can arise if the tests are executed in a different order than you expect.

ewan.chalmers
  • 16,145
  • 43
  • 60
  • Hi, this fixes the keyboard problem, but brings up another error, which only occurs @ jenkins. Do you have any other ideas of solving the problem? – tuergeist Sep 29 '11 at 07:18
  • Not unless you give me a clue ;) I suggest you update your question with the new details. – ewan.chalmers Sep 29 '11 at 07:53
  • they work fine on every developer machine and are independend – tuergeist Oct 03 '11 at 16:55
  • I accepted this answer as it helped a little bit solving the problem. But the main issues isn't solved yet. It looks like the you have to run jenkins as a normal user including an X server / or as Windows user logged in. :( – tuergeist Nov 13 '11 at 14:20
  • Just a wild guess based on "X server needed" - have you tried running your JVM with "java.awt.headless=true"? Probably it would fail sooner without this, but worth trying. – ewan.chalmers Nov 14 '11 at 09:37