2

私はSWTアプリケーション(Eclipse RCPベースではない)を持っており、現在SWTBotを使用してテストしています。これは、Eclipseからテストを実行している間は正常に機能します。ビルドシステムとしてantを使用しています。

Jenkinsではテストが失敗します-例外がスローされます

[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)

この特定の問題を検索しても、役立つ解決策は得られませんでした。

編集:

米国英語を設定するためにjvmargsを追加すると、この問題が修正され、いくつかのテストが実行されます。他のすべては、次のスタックトレースをもたらします。

[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)
4

1 に答える 1

0

java.lang.ExceptionInInitializerErrorについて

DE_DE ロケールのキーボード レイアウトの欠落に関連する Eclipse のバグがある/あったことに気付きました。junit テストを実行しているプロセスのロケール設定を確認することをお勧めします。ロケールを en_US に設定した場合でも問題は発生しますか?

サーバー プロセスのロケールを設定する以外に (たとえば、LC_ALL 環境変数?)、おそらく junit タスクで明示的なロケールを使用できます。

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

org.eclipse.swt.SWTExceptionについて: ウィジェットが破棄されています

これにより、UI コードの実際のバグが明らかになる可能性がありますが、単体テストを確認する必要があると思われます。それらはステートレスですか、それとも確実に動作するために特定の実行順序に依存していますか? おそらく、テストが予想とは異なる順序で実行されると、このエラーが発生する可能性があります。

于 2011-09-27T15:55:44.300 に答える