Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SWTBot/Troubleshooting"

(WidgetNotFoundException when stepping through SWTBot test in Eclipse debugger)
(added troubleshooting guide for ant-junit fragment version mismatch)
Line 24: Line 24:
  
 
This is because when the debugger is in focus, your application is out of focus, which prevents SWTBot from finding its widgets. To fix this problem, just be sure to set any breakpoints after the SWTBot calls you're interested in, and don't expect to be able to step across subsequent SWTBot calls.
 
This is because when the debugger is in focus, your application is out of focus, which prevents SWTBot from finding its widgets. To fix this problem, just be sure to set any breakpoints after the SWTBot calls you're interested in, and don't expect to be able to step across subsequent SWTBot calls.
 +
 +
== Headless Testing Troubleshooting ==
 +
 +
=== Exception in thread "WorkbenchTestable ===
 +
 +
<code>
 +
Exception in thread "WorkbenchTestable" java.lang.ClassCastException:  org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter
 +
    at  org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:331)
 +
    at  org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:208)
 +
    at  org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .runTests(UITestApplication.java:115)
 +
    at  org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
 +
    at java.lang.Thread.run(Thread.java:595)
 +
</code>
 +
 +
The primary reason for this to happen is because you are using the incorrect version of an ant-junit fragment. If you are using swtbot, please ensure that you are not using the eclipse-test-framework's ant-junit fragment '''org.eclipse.ant.optional.junit_*.jar'''. Also ensure that you are using the right version of swtbot's ant-junit fragment that suits your junit version.
 +
 +
See [[SWTBot/Ant#Setup | Ant Setup]] and [http://www.eclipse.org/forums/index.php?t=msg&th=159985&start=0& this thread] for more up-to-date information on setting up dependencies.
  
 
[[Category:Draft Documentation]]
 
[[Category:Draft Documentation]]

Revision as of 12:25, 4 January 2010


SWTBot
Website
Update Sites
Community
Mailing List
Forums/Newsgroups
IRC
Contribute
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration


Troubleshooting

SWTBot fails with"swtbottestapplication" could not be found in the registry

If you get an error like:

java.lang.RuntimeException: Application "org.eclipse.swtbot.eclipse.core.swtbottestapplication" could not be found in the registry.
The applications available are: some.long.list.of.application.ids

Then the most common cause is that the target platform does not have the "org.eclipse.swtbot.eclipse.core" plugin. If you're certain that you have this plugin, but the error persists. Try running with -consoleLog -debug options turned on while running the tests. This would most probably tell you about a missing dependency that causes the plugin to not load.

WidgetNotFoundException when stepping through SWTBot test in Eclipse debugger

If you set a debugger breakpoint in an SWTBot test and then step through it, you may see a WidgetNotFoundException from an SWTBot call that should easily succeed, like

SWTWorkbenchBot bot = new SWTWorkbenchBot();
...
bot.viewByTitle( "MyView" )

This is because when the debugger is in focus, your application is out of focus, which prevents SWTBot from finding its widgets. To fix this problem, just be sure to set any breakpoints after the SWTBot calls you're interested in, and don't expect to be able to step across subsequent SWTBot calls.

Headless Testing Troubleshooting

Exception in thread "WorkbenchTestable

Exception in thread "WorkbenchTestable" java.lang.ClassCastException:  org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter
    at  org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:331)
    at  org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:208)
    at  org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .runTests(UITestApplication.java:115)
    at  org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
    at java.lang.Thread.run(Thread.java:595) 

The primary reason for this to happen is because you are using the incorrect version of an ant-junit fragment. If you are using swtbot, please ensure that you are not using the eclipse-test-framework's ant-junit fragment org.eclipse.ant.optional.junit_*.jar. Also ensure that you are using the right version of swtbot's ant-junit fragment that suits your junit version.

See Ant Setup and this thread for more up-to-date information on setting up dependencies.

Back to the top