首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Jenkins中集成SWTBot测试?

如何在Jenkins中集成SWTBot测试?
EN

Stack Overflow用户
提问于 2011-09-20 08:19:35
回答 1查看 1.6K关注 0票数 2

我有一个SWT应用程序(不是基于Eclipse的),目前我使用SWTBot测试它。在从Eclipse运行测试时,这很好。我用蚂蚁做建筑系统。

在Jenkins上,测试失败--引发异常。

代码语言:javascript
复制
[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)

寻找这一具体问题并没有带来任何有益的解决办法。

编辑:

添加jvm args来设置US,修复这个isse,并运行一些测试;其他所有测试都会带来以下堆栈跟踪:

代码语言:javascript
复制
[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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-27 15:55:44

关于java.lang.ExceptionInInitializerError

我注意到有/已经出现了与缺少DE_DE区域设置的键盘布局有关的Eclipse。我建议您检查运行junit测试的进程的区域设置。如果您将区域设置为en_US,那么问题仍然存在吗?

除了为服务器进程设置区域设置(例如,LC_ALL环境变量?)之外,您还可以在junit任务中使用显式区域设置。

代码语言:javascript
复制
<junit fork="yes">
  <jvmarg value="-Duser.language=en"/>
  <jvmarg value="-Duser.region=US"/>

关于org.eclipse.swt.SWTException:小部件已被释放

也许这在你的UI代码中暴露了一个真正的错误,但我怀疑你需要查看你的单元测试。它们是无状态的,还是依赖于某种执行顺序才能可靠地工作?如果测试以与您预期不同的顺序执行,则可能会出现此错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7482110

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档