Skip to main content
Jump to: navigation, search

Difference between revisions of "SWTBot/UsersGuide"

(no need to call anyone "naive" for no reason)
(Getting started with SWTBot for Eclipse Plugins)
Line 97: Line 97:
Note: SWTBotShell is deprecated in the current release. Replacing it, as recommened with SWTWorkbenchBot doesn't work, as the view(String) method is missing.
===Executing SWTBot Tests for Eclipse Plugins===
===Executing SWTBot Tests for Eclipse Plugins===

Revision as of 08:35, 2 December 2009

Update Sites
Mailing List
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration

SWTBot Users Guide

Note that this page is for first time users. Advanced Users click here.


SWTBot is an open-source Java based functional testing tool for testing SWT and Eclipse based applications.

SWTBot provides APIs that are simple to read and write. The APIs also hide the complexities involved with SWT and Eclipse. This makes it suitable for functional testing by everyone. SWTBot also provides its own set of assertions that are useful for SWT. You can also use your own assertion framework with SWTBot.

SWTBot can record and playback tests and integrates with Eclipse, and also provides for ant tasks so that you can run your builds from within CruiseControl or any other CI tool that you use.

SWTBot can run on all platforms that SWT runs on. Very few other testing tools provide such a wide variety of platforms.

Quick Start

A Screencast

Videos speak louder than pictures and words put together:

Creating A Project

Create a new project by clicking on File>New>Project. On the New Project Dialog, search for "plug-in", select New Plug-in Project and click Next. Create a new plugin project named org.eclipsecon.swtbot.example.



  • Add the following to your classpath:


Getting started with SWTBot

SWTBot requires that tests run on a non-UI thread. If you run tests on the UI thread, they will eventually block the UI at some point in time. More info on this behavior available in the FAQ.

Getting started with SWTBot for Eclipse Plugins

To use SWTBot along with your eclipse plugin application you have to add the below plugins to your dependencies. You can download the example from the swtbot download site

Now you can start using SWTBot. Below you can find a sample SWTBot testcase:

package org.eclipsecon.swtbot.example;
import org.eclipse.swtbot.eclipse.finder.SWTEclipseBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
public class MyFirstTest {
	private static SWTEclipseBot	bot;
	public static void beforeClass() throws Exception {
		bot = new SWTEclipseBot();
	public void canCreateANewJavaProject() throws Exception {"File").menu("New").menu("Project...").click();
		SWTBotShell shell ="New Project");
		bot.tree().select("Java Project");
		bot.button("Next >").click();
		bot.textWithLabel("Project name:").setText("MyFirstProject");
		// FIXME: assert that the project is actually created, for later
	public static void sleep() {

Note: SWTBotShell is deprecated in the current release. Replacing it, as recommened with SWTWorkbenchBot doesn't work, as the view(String) method is missing.

Executing SWTBot Tests for Eclipse Plugins

Now that you've written the great test that you'd always wanted to, lets now see it run. In order to run the test, right click on the test and select Run As > SWTBot Test


Select the application that you want to test


Back to the top