The first step is to install SWTBot from the Eclipse update site. These examples were tested with http://download.eclipse.org/technology/swtbot/releases/latest/ version 2.3.0, but check out the book's errata for up-to-date information.
Go to Help | Install New Software and enter the SWTBot update site.
Select everything except the GEF feature:
Click on Next to install.
Restart Eclipse when prompted.
Add the following bundle dependencies to the plug-in manifest for the
com.packtpub.e4.junit.plugin
project:org.eclipse.swtbot.junit4_x
org.eclipse.swtbot.forms.finder
org.eclipse.swtbot.eclipse.finder
org.eclipse.ui
Create a class called
UITest
in thecom.packtpub.e4.junit.plugin
package.Add a class annotation
@RunWith(SWTBotJunit4ClassRunner.class)
.Create a method called
testUI
and with an annotation@Test
.Inside the
testUI
method, create an instance ofSWTWorkbenchBot
.Iterate through the bot's
shells
and assert that the one that is visible has a title...